js-on-sx: rest in array pattern + nested pattern tolerance
Array destructure now supports [a, ...rest]. Rest entry is transpiled to (define name (js-list-slice tmp i (len tmp))). Nested patterns like [[a,b], c] now parse (as holes) instead of erroring. jp-skip-balanced skips nested groups. 440/442 unit (+2), 148/148 slice unchanged.
This commit is contained in:
@@ -1129,6 +1129,12 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3003)
|
||||
(eval "(js-eval \"[3,1,2].sort((a,b)=>b-a).join(',')\")")
|
||||
|
||||
;; ── Phase 11.destruct2: rest in arr pattern, nested tolerance ──
|
||||
(epoch 3100)
|
||||
(eval "(js-eval \"var [h, ...tl] = [1,2,3,4]; tl.length\")")
|
||||
(epoch 3101)
|
||||
(eval "(js-eval \"var [h, ...tl] = [1,2,3,4]; tl.join(',')\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
|
||||
@@ -1740,6 +1746,10 @@ check 3001 "sort lex (10<5)" '"10,20,5"'
|
||||
check 3002 "sort numeric" '"1,2,3"'
|
||||
check 3003 "sort reverse" '"3,2,1"'
|
||||
|
||||
# ── Phase 11.destruct2 ────────────────────────────────────────
|
||||
check 3100 "rest arr length" '3'
|
||||
check 3101 "rest arr join" '"2,3,4"'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "✓ $PASS/$TOTAL JS-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user