lua: string.format width/zero-pad/hex/octal/char/precision +6 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:
@@ -994,6 +994,20 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1912)
|
||||
(eval "(lua-eval-ast \"return string.match(\\\"abc\\\", \\\"[^a]+\\\")\")")
|
||||
|
||||
;; ── string.format width/precision/hex/octal/char ─────────────
|
||||
(epoch 1920)
|
||||
(eval "(lua-eval-ast \"return string.format('%5d', 42)\")")
|
||||
(epoch 1921)
|
||||
(eval "(lua-eval-ast \"return string.format('%05d', 42)\")")
|
||||
(epoch 1922)
|
||||
(eval "(lua-eval-ast \"return string.format('%x', 255)\")")
|
||||
(epoch 1923)
|
||||
(eval "(lua-eval-ast \"return string.format('%X', 255)\")")
|
||||
(epoch 1924)
|
||||
(eval "(lua-eval-ast \"return string.format('%c', 65)\")")
|
||||
(epoch 1925)
|
||||
(eval "(lua-eval-ast \"return string.format('%.3s', 'hello')\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1508,6 +1522,14 @@ check 1910 "[a-z]+ on hello123" '"hello"'
|
||||
check 1911 "[0-9]+ on hello123" '"123"'
|
||||
check 1912 "[^a]+ on abc" '"bc"'
|
||||
|
||||
# ── string.format width/precision/hex/octal/char ────────────
|
||||
check 1920 "%5d width" '" 42"'
|
||||
check 1921 "%05d zero-pad" '"00042"'
|
||||
check 1922 "%x hex" '"ff"'
|
||||
check 1923 "%X HEX" '"FF"'
|
||||
check 1924 "%c char" '"A"'
|
||||
check 1925 "%.3s precision" '"hel"'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL Lua-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user