lua: io stub (buffered) + print/tostring/tonumber +12 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:
@@ -832,6 +832,32 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1341)
|
||||
(eval "(lua-eval-ast \"local t = {10, 20, 30, 40} local a, b = table.unpack(t, 2, 3) return a + b\")")
|
||||
|
||||
;; ── Phase 6: io stub + print/tostring/tonumber ────────────────
|
||||
(epoch 1400)
|
||||
(eval "(lua-eval-ast \"io.write(\\\"hello\\\") return io.__buffer()\")")
|
||||
(epoch 1401)
|
||||
(eval "(lua-eval-ast \"io.write(\\\"a\\\", \\\"b\\\", \\\"c\\\") return io.__buffer()\")")
|
||||
(epoch 1402)
|
||||
(eval "(lua-eval-ast \"io.write(1, \\\" \\\", 2) return io.__buffer()\")")
|
||||
(epoch 1410)
|
||||
(eval "(lua-eval-ast \"print(\\\"x\\\", \\\"y\\\") return io.__buffer()\")")
|
||||
(epoch 1411)
|
||||
(eval "(lua-eval-ast \"print(1, 2, 3) return io.__buffer()\")")
|
||||
(epoch 1420)
|
||||
(eval "(lua-eval-ast \"return tostring(42)\")")
|
||||
(epoch 1421)
|
||||
(eval "(lua-eval-ast \"return tostring(nil)\")")
|
||||
(epoch 1422)
|
||||
(eval "(lua-eval-ast \"return tostring({})\")")
|
||||
(epoch 1430)
|
||||
(eval "(lua-eval-ast \"return tonumber(\\\"42\\\")\")")
|
||||
(epoch 1431)
|
||||
(eval "(lua-eval-ast \"if tonumber(\\\"abc\\\") == nil then return 1 else return 0 end\")")
|
||||
(epoch 1440)
|
||||
(eval "(lua-eval-ast \"if io.read() == nil then return 1 else return 0 end\")")
|
||||
(epoch 1441)
|
||||
(eval "(lua-eval-ast \"if io.open(\\\"x\\\") == nil then return 1 else return 0 end\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1249,6 +1275,20 @@ check 1331 "table.sort desc via cmp" '301'
|
||||
check 1340 "unpack global" '60'
|
||||
check 1341 "table.unpack(t,i,j)" '50'
|
||||
|
||||
# ── Phase 6: io stub + print/tostring/tonumber ────────────────
|
||||
check 1400 "io.write single" '"hello"'
|
||||
check 1401 "io.write multi strings" '"abc"'
|
||||
check 1402 "io.write numbers + spaces" '"1 2"'
|
||||
check 1410 "print two args tab-sep + NL" '"x\ty\n"'
|
||||
check 1411 "print three ints" '"1\t2\t3\n"'
|
||||
check 1420 "tostring(42)" '"42"'
|
||||
check 1421 "tostring(nil)" '"nil"'
|
||||
check 1422 "tostring({})" '"table"'
|
||||
check 1430 "tonumber(\"42\")" '42'
|
||||
check 1431 "tonumber(\"abc\") → nil" '1'
|
||||
check 1440 "io.read() → nil" '1'
|
||||
check 1441 "io.open(x) → nil" '1'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user