lua: math.mod (alias) + math.frexp + math.ldexp
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-25 00:39:46 +00:00
parent 1b34d41b33
commit f620be096b
4 changed files with 78 additions and 43 deletions

View File

@@ -1425,6 +1425,35 @@
(dict-set! math "min" lua-math-min)
(dict-set! math "max" lua-math-max)
(dict-set! math "fmod" lua-math-fmod)
(dict-set! math "mod" lua-math-fmod)
(define
lua-math-frexp
(fn (x)
(cond
((= x 0) (list (quote lua-multi) 0 0))
(else
(let ((sign (if (< x 0) -1 1)) (ax (abs x)) (e 0))
(begin
(define
fr-up
(fn ()
(when (>= ax 1)
(begin (set! ax (/ ax 2)) (set! e (+ e 1)) (fr-up)))))
(define
fr-dn
(fn ()
(when (< ax 0.5)
(begin (set! ax (* ax 2)) (set! e (- e 1)) (fr-dn)))))
(fr-up)
(fr-dn)
(list (quote lua-multi) (* sign ax) e)))))))
(define
lua-math-ldexp
(fn (m e) (* m (pow 2 e))))
(dict-set! math "frexp" lua-math-frexp)
(dict-set! math "ldexp" lua-math-ldexp)
(dict-set! math "modf" lua-math-modf)
(dict-set! math "random" lua-math-random)
(dict-set! math "randomseed" lua-math-randomseed)

View File

@@ -1,8 +1,8 @@
{
"totals": {
"pass": 1,
"fail": 9,
"timeout": 6,
"fail": 12,
"timeout": 3,
"skip": 8,
"total": 24,
"runnable": 16,
@@ -10,12 +10,12 @@
},
"top_failure_modes": [
[
"timeout",
6
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
7
],
[
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
5
"timeout",
3
],
[
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
@@ -28,6 +28,10 @@
[
"undefined symbol: fat\\",
1
],
[
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
1
]
],
"results": [
@@ -47,7 +51,7 @@
"name": "attrib.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: module 'C' not found\\\\\\\"\\",
"ms": 6985
"ms": 6723
},
{
"name": "big.lua",
@@ -59,7 +63,7 @@
"name": "calls.lua",
"status": "fail",
"reason": "undefined symbol: fat\\",
"ms": 5721
"ms": 5181
},
{
"name": "checktable.lua",
@@ -71,7 +75,7 @@
"name": "closure.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8008
"ms": 8004
},
{
"name": "code.lua",
@@ -81,9 +85,9 @@
},
{
"name": "constructs.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8007
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
"ms": 7350
},
{
"name": "db.lua",
@@ -95,13 +99,13 @@
"name": "errors.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 4667
"ms": 3439
},
{
"name": "events.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8007
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 7915
},
{
"name": "files.lua",
@@ -119,13 +123,13 @@
"name": "literals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 2950
"ms": 2141
},
{
"name": "locals.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 2366
"ms": 1799
},
{
"name": "main.lua",
@@ -137,19 +141,19 @@
"name": "math.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 4991
"ms": 4738
},
{
"name": "nextvar.lua",
"status": "timeout",
"reason": "per-test timeout",
"ms": 8007
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 7818
},
{
"name": "pm.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 6697
"ms": 6478
},
{
"name": "sort.lua",
@@ -161,19 +165,19 @@
"name": "strings.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 4493
"ms": 4339
},
{
"name": "vararg.lua",
"status": "fail",
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 2541
"ms": 2343
},
{
"name": "verybig.lua",
"status": "pass",
"reason": "",
"ms": 1187
"ms": 1064
}
]
}

View File

@@ -1,15 +1,16 @@
# Lua-on-SX conformance scoreboard
**Pass rate:** 1/16 runnable (6.2%)
fail=9 timeout=6 skip=8 total=24
fail=12 timeout=3 skip=8 total=24
## Top failure modes
- **6x** timeout
- **5x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\
- **7x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\
- **3x** timeout
- **2x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio
- **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\
- **1x** undefined symbol: fat\
- **1x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat
## Per-test results
@@ -17,25 +18,25 @@ fail=9 timeout=6 skip=8 total=24
|---|---|---|---:|
| all.lua | skip | driver uses dofile to chain other tests | 0 |
| api.lua | skip | requires testC (C debug library) | 0 |
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6985 |
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6723 |
| big.lua | timeout | per-test timeout | 8008 |
| calls.lua | fail | undefined symbol: fat\ | 5721 |
| calls.lua | fail | undefined symbol: fat\ | 5181 |
| checktable.lua | skip | internal debug helpers | 0 |
| closure.lua | timeout | per-test timeout | 8008 |
| closure.lua | timeout | per-test timeout | 8004 |
| code.lua | skip | bytecode inspection via debug library | 0 |
| constructs.lua | timeout | per-test timeout | 8007 |
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 7350 |
| db.lua | skip | debug library | 0 |
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4667 |
| events.lua | timeout | per-test timeout | 8007 |
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3439 |
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7915 |
| files.lua | skip | io library | 0 |
| gc.lua | skip | collectgarbage / finalisers | 0 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2950 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 2366 |
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2141 |
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1799 |
| main.lua | skip | standalone interpreter driver | 0 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 4991 |
| nextvar.lua | timeout | per-test timeout | 8007 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6697 |
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 4738 |
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7818 |
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6478 |
| sort.lua | timeout | per-test timeout | 8007 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4493 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2541 |
| verybig.lua | pass | - | 1187 |
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 4339 |
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2343 |
| verybig.lua | pass | - | 1064 |

View File

@@ -82,6 +82,7 @@ Each item: implement → tests → tick box → update progress log.
_Newest first. Agent appends on every commit._
- 2026-04-25: lua: scoreboard iteration — `math.mod` (Lua 5.0 alias for `fmod`), `math.frexp` (mantissa/exponent split), `math.ldexp` (m·2^e). math.lua moves past line-103 `math.mod` call. Timeouts 6→3, asserts 5→7. 393/393 green.
- 2026-04-25: lua: scoreboard iteration — `unpack(t, i, j)` now treats explicit nil for `i` or `j` as missing (defaults to 1 and `#t`). vararg.lua-style `unpack(args, 1, args.n)` works when `args.n` is nil. Asserts 4→5, timeouts 8→6 (more tests reach assertions instead of timing out). 393/393 green.
- 2026-04-25: lua: scoreboard iteration — extended `string.format`. New `%x`/`%X`/`%o` (hex/octal), `%c` (codepoint→char via `lua-char-one`), `%q` (basic quote), width N (`%5d`), zero-pad (`%05d`), left-align (`%-5d`), `%.Ns` precision. Helpers `lua-fmt-pad` and `lua-fmt-int-base`. 393/393 green (+6 format tests).
- 2026-04-25: lua: scoreboard iteration — `lua-eval-ast` now SKIPS the top-level guard when the parsed chunk has no top-level `return` (recursive AST walk via `lua-has-top-return?` that descends through control-flow but stops at function-body boundaries). Without the guard, top-level user defines leak to the SX top env, and `loadstring`-captured closures can find them. Verified: `function fat(x)...loadstring("return fat(...)")...end; x=fat(5)` works (was undefined). Most PUC-Rio tests still have top-level returns elsewhere, so they still need the guard. Scoreboard unchanged at 1/16 but unblocks future work.