test(core): ingest reverse-bracket + multi-word-member TCK cases (+8)
public
test(core): ingest reverse-bracket + multi-word-member TCK cases (+8)
Relax `fits_slice_grammar` to match feel-core's now-broader grammar, then re-ingest
the three affected suites:
* Reverse-bracket `..` scan: replace the depth counter (which rejected `]a..b]` as a
close-with-nothing-open and `[a..b[` as unbalanced) with `_value_range_brackets_ok`,
a structural scan that pairs brackets by nesting without requiring types to match
(FEEL intervals mix `[`/`(`/`]`) and resolves reverse roles positionally. Still
rejects a bare top-level `..` and genuine imbalance.
* Multi-word member blanking: `.field` may be a joined multi-word name
(`.start included`, `.end included`, `.time offset`; ADR-17), so consume a run of
words after the dot, stopping at a keyword exactly as the lexer's name-join does
(so `a.b and c` keeps `and c`).
Re-ingest adds 8 cases the closed loop now evaluates: 0068 `(1..10] = ]1..10]` /
`[1..10) = [1..10[` (notation equivalence), 1156 `range("]18..21]") = ]18..21]` /
`range("[18..21[") = [18..21[` (the `range(string)` builtin also parses reverse
brackets), and 0074's four `.time offset` properties.
Not unlocked: 0074's `range_*` decisions are boxed contexts (4 `contextEntry`
literals each), which the ingester does not read — same as 1130's relation table.
The reverse-bracket range *properties* (`]1..10].start included`, …) are covered by
the `range_properties` unit test instead.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| Changeset | 3ab10aa5762f7738f5508901bab87e2ae615d06b |
|---|---|
| Author (claimed) | Timo Stolz <timo.stolz@gmail.com>, |
| Parents | 2599bff7f5a1 |
| Children | |
| Pushlog | by timo via ssh |
modified crates/feel-core/tests/fixtures/0068-feel-equality.json +16 −0
| @@ -608,6 +608,22 @@ | ||
| 608 | 608 | "deviation": null |
| 609 | 609 | }, |
| 610 | 610 | { |
| 611 | + "id": "0068-feel-equality:range_004:range_004", | |
| 612 | + "expression": "(1..10] = ]1..10]", | |
| 613 | + "expected": true, | |
| 614 | + "expected_type": "boolean", | |
| 615 | + "comparison": "exact", | |
| 616 | + "deviation": null | |
| 617 | + }, | |
| 618 | + { | |
| 619 | + "id": "0068-feel-equality:range_005:range_005", | |
| 620 | + "expression": "[1..10) = [1..10[", | |
| 621 | + "expected": true, | |
| 622 | + "expected_type": "boolean", | |
| 623 | + "comparison": "exact", | |
| 624 | + "deviation": null | |
| 625 | + }, | |
| 626 | + { | |
| 611 | 627 | "id": "0068-feel-equality:string_001:string_001", |
| 612 | 628 | "expression": "\"foo\" = \"foo\"", |
| 613 | 629 | "expected": true, |
modified crates/feel-core/tests/fixtures/0074-feel-properties.json +32 −0
| @@ -98,6 +98,22 @@ | ||
| 98 | 98 | "epsilon": 1e-08 |
| 99 | 99 | }, |
| 100 | 100 | { |
| 101 | + "id": "0074-feel-properties:dateTime_008:dateTime_008", | |
| 102 | + "expression": "date and time(\"2018-12-10T10:30:00+05:00\").time offset", | |
| 103 | + "expected": "PT5H", | |
| 104 | + "expected_type": "duration", | |
| 105 | + "comparison": "exact", | |
| 106 | + "deviation": "Temporal result compared in feel-core's canonical ISO-8601 form (ADR-18). feel-core backs temporal values with jiff; at the wrappers they cross the boundary as ISO-8601 strings, so PostgreSQL can cast to date/timestamptz/interval (ADR-5's interval mapping) and WASM can return JS Date objects." | |
| 107 | + }, | |
| 108 | + { | |
| 109 | + "id": "0074-feel-properties:dateTime_008_a:dateTime_008_a", | |
| 110 | + "expression": "date and time(\"2018-12-10T10:30:00\").time offset", | |
| 111 | + "expected": null, | |
| 112 | + "expected_type": "null", | |
| 113 | + "comparison": "exact", | |
| 114 | + "deviation": null | |
| 115 | + }, | |
| 116 | + { | |
| 101 | 117 | "id": "0074-feel-properties:dateTime_009:dateTime_009", |
| 102 | 118 | "expression": "date and time(\"2018-12-10T10:30:00@Etc/UTC\").timezone", |
| 103 | 119 | "expected": "Etc/UTC", |
| @@ -265,6 +281,22 @@ | ||
| 265 | 281 | "epsilon": 1e-08 |
| 266 | 282 | }, |
| 267 | 283 | { |
| 284 | + "id": "0074-feel-properties:time_004:time_004", | |
| 285 | + "expression": "time(\"10:30:00+05:00\").time offset", | |
| 286 | + "expected": "PT5H", | |
| 287 | + "expected_type": "duration", | |
| 288 | + "comparison": "exact", | |
| 289 | + "deviation": "Temporal result compared in feel-core's canonical ISO-8601 form (ADR-18). feel-core backs temporal values with jiff; at the wrappers they cross the boundary as ISO-8601 strings, so PostgreSQL can cast to date/timestamptz/interval (ADR-5's interval mapping) and WASM can return JS Date objects." | |
| 290 | + }, | |
| 291 | + { | |
| 292 | + "id": "0074-feel-properties:time_004_a:time_004_a", | |
| 293 | + "expression": "time(\"10:30:00\").time offset", | |
| 294 | + "expected": null, | |
| 295 | + "expected_type": "null", | |
| 296 | + "comparison": "exact", | |
| 297 | + "deviation": null | |
| 298 | + }, | |
| 299 | + { | |
| 268 | 300 | "id": "0074-feel-properties:time_005_a:time_005_a", |
| 269 | 301 | "expression": "time(\"10:30:00\").timezone", |
| 270 | 302 | "expected": null, |
modified crates/feel-core/tests/fixtures/1156-range-function.json +16 −0
| @@ -72,8 +72,24 @@ | ||
| 72 | 72 | "deviation": null |
| 73 | 73 | }, |
| 74 | 74 | { |
| 75 | + "id": "1156-range-function:003_c:decision003_c", | |
| 76 | + "expression": "range(\"]18..21]\") = ]18..21]", | |
| 77 | + "expected": true, | |
| 78 | + "expected_type": "boolean", | |
| 79 | + "comparison": "exact", | |
| 80 | + "deviation": null | |
| 81 | + }, | |
| 82 | + { | |
| 75 | 83 | "id": "1156-range-function:003_d:decision003_d", |
| 76 | 84 | "expression": "range(\"[18..21)\") = [18..21)", |
| 85 | + "expected": true, | |
| 86 | + "expected_type": "boolean", | |
| 87 | + "comparison": "exact", | |
| 88 | + "deviation": null | |
| 89 | + }, | |
| 90 | + { | |
| 91 | + "id": "1156-range-function:003_e:decision003_e", | |
| 92 | + "expression": "range(\"[18..21[\") = [18..21[", | |
| 77 | 93 | "expected": true, |
| 78 | 94 | "expected_type": "boolean", |
| 79 | 95 | "comparison": "exact", |
modified tools/ingest_tck.py +60 −26
| @@ -139,6 +139,48 @@ | ||
| 139 | 139 | return False # unbalanced |
| 140 | 140 | |
| 141 | 141 | |
| 142 | +def _value_range_brackets_ok(s: str) -> bool: | |
| 143 | + """True if every `..` in value-position `s` sits inside a bracketed range literal / | |
| 144 | + interval feel-core parses — INCLUDING the reverse-bracket spellings `]a..b]` | |
| 145 | + (exclusive lower, ≡ `(a..b]`) and `[a..b[` (exclusive upper, ≡ `[a..b)`), both | |
| 146 | + shipped now. A structural scan that does NOT require bracket *types* to match: FEEL | |
| 147 | + intervals legitimately mix `[`/`(`/`]` (`(1..2]`), so an opener and a closer pair by | |
| 148 | + nesting alone. Reverse roles resolve positionally — a `]` with nothing open is a | |
| 149 | + reverse-open opener; a `[` whose innermost group already holds a `..` is a | |
| 150 | + reverse-close closer. Rejects a bare top-level `..` and stray / unbalanced brackets; | |
| 151 | + a few exotic shapes not in the TCK (a reverse-open as a list's first element, | |
| 152 | + `[a..[list]]`) are conservatively skipped rather than risk a false positive (which | |
| 153 | + would crash the closed-loop fixture test).""" | |
| 154 | + stack: list[bool] = [] # one flag per open group: has a `..` been seen inside it | |
| 155 | + i = 0 | |
| 156 | + while i < len(s): | |
| 157 | + if s[i : i + 2] == "..": | |
| 158 | + if not stack: | |
| 159 | + return False # bare top-level `..` | |
| 160 | + stack[-1] = True | |
| 161 | + i += 2 | |
| 162 | + continue | |
| 163 | + c = s[i] | |
| 164 | + if c == "(": | |
| 165 | + stack.append(False) | |
| 166 | + elif c == "[": | |
| 167 | + if stack and stack[-1]: # inside a `..` group -> reverse-close `[a..b[` | |
| 168 | + stack.pop() | |
| 169 | + else: | |
| 170 | + stack.append(False) | |
| 171 | + elif c == "]": | |
| 172 | + if stack: | |
| 173 | + stack.pop() | |
| 174 | + else: # nothing open -> reverse-open `]a..b]` | |
| 175 | + stack.append(False) | |
| 176 | + elif c == ")": | |
| 177 | + if not stack: | |
| 178 | + return False # close with nothing open | |
| 179 | + stack.pop() | |
| 180 | + i += 1 | |
| 181 | + return not stack # leftover open group -> unbalanced | |
| 182 | + | |
| 183 | + | |
| 142 | 184 | def _in_rhs_supported(after: str) -> bool: |
| 143 | 185 | """True if the text after a membership `in` is a slice-supported positive unary |
| 144 | 186 | test: a single comparison `<op> endpoint` (`< 10`, `= e`, `!= e`), a bracket/paren |
| @@ -236,8 +278,17 @@ | ||
| 236 | 278 | # Free identifiers: not a keyword, not a loop variable bound by an enclosing |
| 237 | 279 | # for/some/every, not a captured input name. Member segments (`.field`) and |
| 238 | 280 | # context-literal keys (`field:`) are structural, not free names, so blank |
| 239 | - # them out before scanning. The single-dot match excludes `..` ranges. | |
| 240 | - scan = re.sub(r"(?<!\.)\.(?!\.)\s*[A-Za-z_]\w*", " ", s) # drop `.field` | |
| 281 | + # them out before scanning. The single-dot match excludes `..` ranges. A member | |
| 282 | + # name may be multi-word (`.start included`, `.end included`, `.time offset`; the | |
| 283 | + # lexer joins adjacent name words, ADR-17), so consume a run of words after the | |
| 284 | + # dot — stopping at a keyword, exactly as the lexer's join stops at a keyword | |
| 285 | + # token (so `a.b and c` keeps `and c`). | |
| 286 | + _kw_alt = "|".join(sorted(_KEYWORDS, key=len, reverse=True)) | |
| 287 | + scan = re.sub( | |
| 288 | + r"(?<!\.)\.(?!\.)\s*[A-Za-z_]\w*(?:\s+(?!(?:" + _kw_alt + r")\b)[A-Za-z_]\w*)*", | |
| 289 | + " ", | |
| 290 | + s, | |
| 291 | + ) # drop `.field` (incl. multi-word members) | |
| 241 | 292 | # Drop context-literal keys and named-argument parameter names (`key:`). Both |
| 242 | 293 | # may be multi-word FEEL names (`{full name: …}`, `substring(start position: …)`, |
| 243 | 294 | # `number(decimal separator: …)`), so consume the whole space-separated run up to |
| @@ -283,30 +334,13 @@ | ||
| 283 | 334 | # in both the TCK and feel-core, so they stay in the slice. |
| 284 | 335 | else: |
| 285 | 336 | # Outside an iteration, a `..` is legal inside a *bracketed* range literal |
| 286 | - # / interval — either a first-class range value (`[18..21] = [18..21]`, | |
| 287 | - # `[1..10] instance of range<number>`) or a membership-interval RHS | |
| 288 | - # (`x in [a..b]`, validated further by the membership scan below). Rejected: | |
| 289 | - # * a bare, top-level `..` (`1..3` as a value) — not a valid expression; | |
| 290 | - # * the reverse-bracket interval notation `]a..b]` / `[a..b[` (DMN allows | |
| 291 | - # `]`/`[` as open/close, but feel-core's grammar does not), detected as | |
| 292 | - # a close bracket with nothing open, or an unbalanced bracket run. | |
| 293 | - depth = 0 | |
| 294 | - i = 0 | |
| 295 | - while i < len(s): | |
| 296 | - c = s[i] | |
| 297 | - if c in "[(": | |
| 298 | - depth += 1 | |
| 299 | - elif c in "])": | |
| 300 | - depth -= 1 | |
| 301 | - if depth < 0: # close with nothing open -> reverse `]a..b]` | |
| 302 | - return False | |
| 303 | - elif s[i : i + 2] == "..": | |
| 304 | - if depth == 0: # bare top-level `..` | |
| 305 | - return False | |
| 306 | - i += 2 | |
| 307 | - continue | |
| 308 | - i += 1 | |
| 309 | - if depth != 0: # unbalanced, e.g. the reverse-close `[a..b[` | |
| 337 | + # / interval — a first-class range value (`[18..21] = [18..21]`, | |
| 338 | + # `[1..10] instance of range<number>`, `]1..10].start`) or a | |
| 339 | + # membership-interval RHS (`x in [a..b]`, validated further by the | |
| 340 | + # membership scan below). The reverse-bracket spellings `]a..b]` / `[a..b[` | |
| 341 | + # are in scope now (shipped), so the structural scan accepts them and | |
| 342 | + # rejects only a bare top-level `..` or genuinely unbalanced brackets. | |
| 343 | + if not _value_range_brackets_ok(s): | |
| 310 | 344 | return False |
| 311 | 345 | |
| 312 | 346 | # Membership `in` (not a for/some/every iterator). The slice supports a single |