Public repository: timo / feel

Reader

An interpreter of FEEL, written in Rust, with integrations for PostgreSQL, WASM, Lua, and Python.

test(core): re-ingest 0068 paren-comparison values + unit test

public

test(core): re-ingest 0068 paren-comparison values + unit test

The ingester's value-position paren-comparison reject now fires only for a
bracket-led comparison (`[< 10]`, which has no grammar production) not
directly after `in`; the paren form `(< 10)` is admitted as the new
opaque unary-test value. Re-ingested `0068-feel-equality` 101 → 109 (the
eight `range_006`/`range_007…012` cases, incl. the ADR-28-deferred
`range_006`); closed loop green.

`value_position_comparison_test` covers the reflexive true / range-
incompatible false pairs, the operator/endpoint structural cases,
`string(...)`, and a regression block proving the `in`-position test
forms are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Changeseta6c02bdaa19fb3fa595304a0df4b4b2b64216dac
Author (claimed)Timo Stolz <timo.stolz@gmail.com>,
Parents22b4fc65594a
Children
Pushlog
by timo via ssh

modified crates/feel-core/src/lib.rs +43 −0

@@ -531,6 +531,49 @@
531531
                 "expected a parse error for closed-bracket unbounded `{src}`"
532532
             );
533533
         }
534
+    }
535
+
536
+    #[test]
537
+    fn value_position_comparison_test() {
538
+        // A parenthesised comparison test in VALUE position — `(< 10)`, `(= 10)`,
539
+        // `(!= 10)` — is an OPAQUE unary-test value (ADR-32), not a boolean and not a
540
+        // promoted range. The measured TCK semantics (0068): it equals a *structurally
541
+        // identical* test reflexively, but is NEVER equal to a `Range`.
542
+        assert_eq!(ev("(<10) = (<10)"), b(true));
543
+        assert_eq!(ev("(=10) = (=10)"), b(true));
544
+        assert_eq!(ev("(!=10) = (!=10)"), b(true));
545
+        // Whitespace inside the parens is irrelevant; every operator spelling works.
546
+        assert_eq!(ev("(<= 10) = (<= 10)"), b(true));
547
+        assert_eq!(ev("(>= 10) = (>= 10)"), b(true));
548
+        assert_eq!(ev("(> 10) = (> 10)"), b(true));
549
+
550
+        // Range-INCOMPATIBLE: equal to no `Range`, whatever the spelling — the crux that
551
+        // falsified the desugar-to-range hypothesis (ADR-28). A definite `false`.
552
+        assert_eq!(ev("(<10) = (null..10)"), b(false));
553
+        assert_eq!(ev("(=10) = [10..10]"), b(false));
554
+        assert_eq!(ev("(<10) = (..10)"), b(false)); // not even the unbounded `(..10)`
555
+
556
+        // Structural, not loose: a different operator or endpoint is `false`.
557
+        assert_eq!(ev("(<10) = (>10)"), b(false));
558
+        assert_eq!(ev("(<10) = (<=10)"), b(false));
559
+        assert_eq!(ev("(<10) = (<11)"), b(false));
560
+        // …and against anything else (a plain number, a list) it is `false`, not error.
561
+        assert_eq!(ev("(<10) = 10"), b(false));
562
+        assert_eq!(ev("(=10) = [10]"), b(false));
563
+
564
+        // string() renders the written parenthesised form (endpoint quoted as a member).
565
+        assert_eq!(ev("string((<10))"), Value::String("(< 10)".into()));
566
+        assert_eq!(ev("string((!=10))"), Value::String("(!= 10)".into()));
567
+        assert_eq!(ev(r#"string((="x"))"#), Value::String("(= \"x\")".into()));
568
+
569
+        // REGRESSION: the `in`-position forms (ADR-28) are a *test*, unchanged — they
570
+        // still membership-test, never construct an opaque value.
571
+        assert_eq!(ev("10 in (=10)"), b(true));
572
+        assert_eq!(ev("5 in (=10)"), b(false));
573
+        assert_eq!(ev("5 in (!=10)"), b(true));
574
+        assert_eq!(ev("10 in (!=10)"), b(false));
575
+        assert_eq!(ev("5 in (<10)"), b(true));
576
+        assert_eq!(ev("15 in (<10)"), b(false));
534577
     }
535578
 
536579
     #[test]

modified crates/feel-core/tests/fixtures/0068-feel-equality.json +64 −0

@@ -624,6 +624,70 @@
624624
     "deviation": null
625625
   },
626626
   {
627
+    "id": "0068-feel-equality:range_006:range_006",
628
+    "expression": "(< 10) = (null..10)",
629
+    "expected": false,
630
+    "expected_type": "boolean",
631
+    "comparison": "exact",
632
+    "deviation": null
633
+  },
634
+  {
635
+    "id": "0068-feel-equality:range_006_a:range_006_a",
636
+    "expression": "(< 10) = (< 10)",
637
+    "expected": true,
638
+    "expected_type": "boolean",
639
+    "comparison": "exact",
640
+    "deviation": null
641
+  },
642
+  {
643
+    "id": "0068-feel-equality:range_007:range_007",
644
+    "expression": "(<= 10) = (null..10]",
645
+    "expected": false,
646
+    "expected_type": "boolean",
647
+    "comparison": "exact",
648
+    "deviation": null
649
+  },
650
+  {
651
+    "id": "0068-feel-equality:range_008:range_008",
652
+    "expression": "(> 10) = (10..null)",
653
+    "expected": false,
654
+    "expected_type": "boolean",
655
+    "comparison": "exact",
656
+    "deviation": null
657
+  },
658
+  {
659
+    "id": "0068-feel-equality:range_009:range_009",
660
+    "expression": "(>= 10) = [10..null)",
661
+    "expected": false,
662
+    "expected_type": "boolean",
663
+    "comparison": "exact",
664
+    "deviation": null
665
+  },
666
+  {
667
+    "id": "0068-feel-equality:range_010:range_010",
668
+    "expression": "(=10) = [10..10]",
669
+    "expected": false,
670
+    "expected_type": "boolean",
671
+    "comparison": "exact",
672
+    "deviation": null
673
+  },
674
+  {
675
+    "id": "0068-feel-equality:range_011:range_011",
676
+    "expression": "(=10) = (=10)",
677
+    "expected": true,
678
+    "expected_type": "boolean",
679
+    "comparison": "exact",
680
+    "deviation": null
681
+  },
682
+  {
683
+    "id": "0068-feel-equality:range_012:range_012",
684
+    "expression": "(!=10) = (!=10)",
685
+    "expected": true,
686
+    "expected_type": "boolean",
687
+    "comparison": "exact",
688
+    "deviation": null
689
+  },
690
+  {
627691
     "id": "0068-feel-equality:string_001:string_001",
628692
     "expression": "\"foo\" = \"foo\"",
629693
     "expected": true,

modified tools/ingest_tck.py +9 −6

@@ -254,12 +254,15 @@
254254
             return False
255255
         s = value_expr
256256
 
257
-    # A parenthesised comparison test in *value* position — `(< 10)`, `(=10)` — is a
258
-    # range-as-value form not yet supported (Form 4 / ROADMAP); reject it. The SAME
259
-    # shape directly after a membership `in` IS supported now (a one-element paren
260
-    # test-list `x in (=10)` ≡ `Compare(Eq, 10)`; Form 1), so only reject an open
261
-    # bracket/paren + comparison that does not directly follow an `in`.
262
-    for _m in re.finditer(r"[\[(]\s*(?:<=|>=|!=|<|>|=)", s):
257
+    # A parenthesised comparison test in *value* position — `(< 10)`, `(=10)`,
258
+    # `(!=10)` — is now an OPAQUE unary-test value (ADR-32): `Primary → "(" CmpOp Sum
259
+    # ")"`, an opaque `Value::UnaryTestVal` with reflexive, range-incompatible equality.
260
+    # So the paren form is SUPPORTED, in value position as well as directly after a
261
+    # membership `in` (the one-element paren test-list `x in (=10)`; ADR-28). Only the
262
+    # bracket-led leading comparison `[< 10]` has no grammar production, so it stays out
263
+    # of the slice — and, as before, only when it does not directly follow an `in` (a
264
+    # bracket test-list `x in [<5, >10]` is a supported positive unary test).
265
+    for _m in re.finditer(r"\[\s*(?:<=|>=|!=|<|>|=)", s):
263266
         if not re.search(r"(?:^|[^\w])in\s*$", s[: _m.start()]):
264267
             return False
265268