lua: multi-return + unpack at call sites (+10 tests)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
This commit is contained in:
@@ -460,6 +460,28 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 561)
|
||||
(eval "(lua-eval-ast \"local function sum_to(n) local s = 0 for i = 1, n do s = s + i end return s end return sum_to(10)\")")
|
||||
|
||||
;; ── Phase 3: multi-return + unpack ────────────────────────────
|
||||
(epoch 570)
|
||||
(eval "(lua-eval-ast \"local a, b = (function() return 1, 2 end)() return a + b\")")
|
||||
(epoch 571)
|
||||
(eval "(lua-eval-ast \"local function two() return 10, 20 end local a, b = two() return b - a\")")
|
||||
(epoch 572)
|
||||
(eval "(lua-eval-ast \"function swap(a, b) return b, a end local x, y = swap(1, 2) return x * 10 + y\")")
|
||||
(epoch 573)
|
||||
(eval "(lua-eval-ast \"local function three() return 1, 2, 3 end local a, b = three() return a * 10 + b\")")
|
||||
(epoch 574)
|
||||
(eval "(lua-eval-ast \"local function two() return 1, 2 end local a, b, c = two() if c == nil then return a + b else return 0 end\")")
|
||||
(epoch 575)
|
||||
(eval "(lua-eval-ast \"local function two() return 5, 7 end local function outer() return two() end local a, b = outer() return a + b\")")
|
||||
(epoch 576)
|
||||
(eval "(lua-eval-ast \"local function two() return 9, 9 end local a, b = two(), 5 return a * 10 + b\")")
|
||||
(epoch 577)
|
||||
(eval "(lua-eval-ast \"local function pair() return 4, 5 end local x = pair() return x + 1\")")
|
||||
(epoch 578)
|
||||
(eval "(lua-eval-ast \"local function none() return end local a, b = none() if a == nil and b == nil then return 99 else return 0 end\")")
|
||||
(epoch 579)
|
||||
(eval "(lua-eval-ast \"local a = 0 local b = 0 local function m() return 7, 11 end a, b = m() return a + b\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -710,6 +732,18 @@ check 551 "twice(+1, 5)" '7'
|
||||
check 560 "max with if" '7'
|
||||
check 561 "sum_to(10) with for" '55'
|
||||
|
||||
# ── Phase 3: multi-return + unpack ────────────────────────────
|
||||
check 570 "anon-fn returns 2, unpack" '3'
|
||||
check 571 "local fn returns 2, unpack" '10'
|
||||
check 572 "swap via multi-return" '21'
|
||||
check 573 "extra returns discarded" '12'
|
||||
check 574 "missing returns nil-padded" '3'
|
||||
check 575 "tail-return passthrough" '12'
|
||||
check 576 "non-last call truncated to 1st" '95'
|
||||
check 577 "single-assign truncates to 1st" '5'
|
||||
check 578 "empty return → all nil" '99'
|
||||
check 579 "multi-assign (non-local)" '18'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user