lua: tonumber(s, base) for bases 2-36 +3 tests; math.lua past assert #21
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:
@@ -978,6 +978,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1895)
|
||||
(eval "(lua-eval-ast \"if string.find(\\\"hello\\\", \\\"^wor\\\") then return 0 else return 1 end\")")
|
||||
|
||||
;; ── tonumber with base (Lua 5.1) ──────────────────────────────
|
||||
(epoch 1900)
|
||||
(eval "(lua-eval-ast \"return tonumber('1010', 2)\")")
|
||||
(epoch 1901)
|
||||
(eval "(lua-eval-ast \"return tonumber('FF', 16)\")")
|
||||
(epoch 1902)
|
||||
(eval "(lua-eval-ast \"if tonumber('99', 8) == nil then return 1 else return 0 end\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1482,6 +1490,11 @@ check 1893 "gsub %d → X" '"X + X = X:3"'
|
||||
check 1894 "find ^ anchor hit" '1'
|
||||
check 1895 "find ^ anchor miss" '1'
|
||||
|
||||
# ── tonumber with base ───────────────────────────────────────
|
||||
check 1900 "tonumber('1010', 2)" '10'
|
||||
check 1901 "tonumber('FF', 16)" '255'
|
||||
check 1902 "tonumber('99', 8) → 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