Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions crates/eql-tests-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,26 @@ fn scalar_type_impls_tokens(list: &ScalarList) -> TokenStream2 {
quote! {
impl ScalarType for #rust_type {
const PG_TYPE: &'static str = #token_str;

/// The catalog `eql_scalars::*_VALUES` list — the same values
/// the fixture generator encrypts, so the oracle can't drift
/// from the fixture.
const FIXTURE_VALUES: &'static [#rust_type] = ::eql_scalars::#values;
/// from the fixture. A method (not a `const`) so non-integer
/// scalars whose values can't be `const`-constructed can return
/// a borrow of a lazily-built `Vec`; integer scalars hand back
/// their catalog const directly.
fn fixture_values() -> &'static [#rust_type] {
::eql_scalars::#values
}

/// Integer scalars pivot on their inherent `MIN`/`MAX` consts;
/// the fixture lists include both (`fixtures!(int …; Min, …, Max)`).
fn min_pivot() -> #rust_type {
<#rust_type>::MIN
}

fn max_pivot() -> #rust_type {
<#rust_type>::MAX
}
}
}
});
Expand Down Expand Up @@ -249,6 +265,15 @@ mod tests {
assert!(out.contains(r#"const PG_TYPE : & 'static str = "int8""#));
assert!(out.contains(":: eql_scalars :: INT4_VALUES"));
assert!(out.contains(":: eql_scalars :: INT8_VALUES"));
// const→fn: fixture values is a method now, plus the integer pivots.
assert!(out.contains("fn fixture_values"));
// Assert the emitted pivot bodies, not bare `MIN`/`MAX` substrings:
// the latter also appear in the doc comment, so a loose check would
// pass even if the bodies stopped returning the inherent bounds.
assert!(out.contains("fn min_pivot () -> i32 { < i32 > :: MIN }"));
assert!(out.contains("fn max_pivot () -> i32 { < i32 > :: MAX }"));
assert!(out.contains("fn min_pivot () -> i64 { < i64 > :: MIN }"));
assert!(out.contains("fn max_pivot () -> i64 { < i64 > :: MAX }"));
}

#[test]
Expand Down
Loading