Log
da0598b30fa6
test(core): `in not(...)` negation unit tests + ingester support
public
test(core): `in not(...)` negation unit tests + ingester support
`membership_not_test_negation` covers list / bare-endpoint / comparison /
interval / mixed inner tests and the Kleene-null case. The ingester's
`_in_rhs_supported` now admits `not(…)` after `in` (validated as a balanced
paren group). The DMN-TCK has no `in not(…)` case in any suite, so no fixture
changed and no suite was re-ingested.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
modified
crates/feel-core/src/lib.rs
+23 −0
@@ -829,6 +829,29 @@
829 829 } 830 830 831 831 #[ test ] 832 + fn membership_not_test_negation () { 833 + // `x in not(...)` is *test* negation (DMN rule 49), not the boolean built-in: 834 + // `x in not(t)` ≡ `not(x satisfies t)`, three-valued. 835 + // List negation: `not(1,2,3)` ≡ `not(x = 1 or x = 2 or x = 3)`. 836 + assert_eq! (ev(" 5 in not(1, 2, 3) " ), b(true )); 837 + assert_eq! (ev(" 2 in not(1, 2, 3) " ), b(false )); 838 + // Single bare endpoint: `not(5)` negates the `= 5` test. 839 + assert_eq! (ev(" 4 in not(5) " ), b(true )); 840 + assert_eq! (ev(" 5 in not(5) " ), b(false )); 841 + // Comparison test negation: `not(< 5)` ≡ `not(x < 5)`. 842 + assert_eq! (ev(" 7 in not(< 5) " ), b(true )); 843 + assert_eq! (ev(" 3 in not(< 5) " ), b(false )); 844 + // Interval test negation: `not([1..10])` ≡ `not(1 <= x <= 10)`. 845 + assert_eq! (ev(" 11 in not([1..10]) " ), b(true )); 846 + assert_eq! (ev(" 5 in not([1..10]) " ), b(false )); 847 + // Mixed inner tests OR-fold before negation. 848 + assert_eq! (ev(" 8 in not(< 5, > 10) " ), b(true )); 849 + assert_eq! (ev(" 3 in not(< 5, > 10) " ), b(false )); 850 + // Kleene: negating an unknown (a null bound) stays null, never a definite true. 851 + assert_eq! (ev(" 5 in not((null..10]) " ), Value::Null); 852 + } 853 + 854 + #[ test ] 832 855 fn if_then_else () { 833 856 assert_eq! (ev(" if true then 1 else 2 " ), num(1.0 )); 834 857 assert_eq! (ev(" if false then 1 else 2 " ), num(2.0 ));
modified
tools/ingest_tck.py
+12 −4
@@ -186,11 +186,19 @@
186 186 test: a single comparison `<op> endpoint` (`< 10`, `= e`, `!= e`), a bracket/paren 187 187 group — a single interval `[a..b]`/`(a..b)` OR a comma-list / parenthesised list of 188 188 tests (`[2,3,1]`, `(false,true)`, `(1,<5,>=10)`, `[[a..b],[c..d]]`, `(=10)`), all 189 - now parsed as positive unary tests (Form 1) — or a *bare endpoint* expression: a 190 - scalar (`1 in 1` is `1 = 1`) or an expression yielding a range 191 - (`2 in range("[1..3]")` is membership). Endpoints may be function calls; names are 192 - pre-validated by the free-name scan in `fits_slice_grammar`.""" 189 + now parsed as positive unary tests (Form 1) — a `not(…)` *test negation* 190 + (`not(1,2,3)`, `not(<5)`, `not([1..10])`; DMN rule 49, ≡ `not(x satisfies t)`) — or 191 + a *bare endpoint* expression: a scalar (`1 in 1` is `1 = 1`) or an expression 192 + yielding a range (`2 in range("[1..3]")` is membership). Endpoints may be function 193 + calls; names are pre-validated by the free-name scan in `fits_slice_grammar`.""" 193 194 t = after. lstrip() 195 + # `not(…)` after `in` is unary-test negation, parsed by the dedicated `InRhs` 196 + # production (never the boolean built-in). Validate the parenthesised test list as 197 + # a balanced group, exactly like a bare bracket group. 198 + m = re. match(r " not \ b \ s* " , t) 199 + if m: 200 + rest = t[m. end() :] 201 + return rest[:1 ] == " ( " and _balanced_bracket_group(rest) 194 202 if re. match(r " <=|>=|!=|<|>|= " , t): 195 203 return True 196 204 if t[:1 ] in " [( " :