lua: scoreboard iteration — rawget/rawset/raweq/rawlen + loadstring/load + select/assert + _G/_VERSION
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled

This commit is contained in:
2026-04-24 19:29:08 +00:00
parent 24fde8aa2f
commit cf4d19fb94
4 changed files with 171 additions and 59 deletions

View File

@@ -1340,3 +1340,104 @@
(else (error (str "lua: module '" name "' not found")))))) (else (error (str "lua: module '" name "' not found"))))))
(define require lua-require) (define require lua-require)
;; ── raw operations + loadstring ───────────────────────────────
(define
lua-rawget
(fn (t k)
(cond
((not (= (type-of t) "dict")) nil)
((has-key? t (str k)) (get t (str k)))
(else nil))))
(define
lua-rawset
(fn (t k v)
(begin (dict-set! t (str k) v) t)))
(define
lua-rawequal
(fn (a b)
(cond
((and (= a nil) (= b nil)) true)
((or (= a nil) (= b nil)) false)
((and (= (type-of a) (type-of b)) (= a b)) true)
(else false))))
(define
lua-rawlen
(fn (v)
(cond
((= (type-of v) "string") (len v))
((= (type-of v) "dict")
(let ((n 0))
(begin
(define
rl-count
(fn (i)
(if (has-key? v (str i))
(begin (set! n i) (rl-count (+ i 1)))
n)))
(rl-count 1)
n)))
(else 0))))
(define rawget lua-rawget)
(define rawset lua-rawset)
(define rawequal lua-rawequal)
(define rawlen lua-rawlen)
;; loadstring(src) returns a function that, when called, evaluates src.
(define
lua-loadstring
(fn (src)
(fn (&rest args) (lua-eval-ast src))))
(define loadstring lua-loadstring)
(define load lua-loadstring)
;; select(n, ...) — Lua 5.1 built-in. select("#", ...) is arg count; select(i, ...) returns args from i on.
(define
lua-select
(fn (&rest args)
(let ((n (first args)) (rest-args (rest args)))
(cond
((= n "#") (len rest-args))
((= (type-of n) "number")
(let ((i (- n 1)))
(cond
((< i 0) (error "lua: bad argument to select"))
((>= i (len rest-args)) nil)
(else
(let ((out (list (quote lua-multi))))
(begin
(define
sel-loop
(fn (j)
(when (< j (len rest-args))
(begin
(set! out (append out (list (nth rest-args j))))
(sel-loop (+ j 1))))))
(sel-loop i)
out))))))
(else (error "lua: bad argument to select"))))))
(define select lua-select)
;; assert(v, msg) — errors with msg if v is falsy.
(define
lua-assert
(fn (&rest args)
(let ((v (first args)))
(cond
((lua-truthy? v)
(cond
((= (len args) 1) v)
(else (cons (quote lua-multi) args))))
(else
(error (if (> (len args) 1) (nth args 1) "assertion failed!")))))))
(define assert lua-assert)
(define _G {})
(define _VERSION "Lua 5.1")

View File

@@ -1,24 +1,32 @@
{ {
"totals": { "totals": {
"pass": 0, "pass": 0,
"fail": 16, "fail": 15,
"timeout": 0, "timeout": 1,
"skip": 8, "skip": 8,
"total": 24, "total": 24,
"runnable": 16, "runnable": 16,
"pass_rate": 0.0 "pass_rate": 0.0
}, },
"top_failure_modes": [ "top_failure_modes": [
[
"parse error",
14
],
[
"undefined symbol: print\\",
1
],
[ [
"transpile: unsupported node", "transpile: unsupported node",
6
],
[
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
4
],
[
"parse error",
3
],
[
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
2
],
[
"timeout",
1 1
] ]
], ],
@@ -38,20 +46,20 @@
{ {
"name": "attrib.lua", "name": "attrib.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "transpile: unsupported node",
"ms": 3243 "ms": 5378
}, },
{ {
"name": "big.lua", "name": "big.lua",
"status": "fail", "status": "timeout",
"reason": "undefined symbol: print\\", "reason": "per-test timeout",
"ms": 4383 "ms": 8007
}, },
{ {
"name": "calls.lua", "name": "calls.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "transpile: unsupported node",
"ms": 3565 "ms": 4393
}, },
{ {
"name": "checktable.lua", "name": "checktable.lua",
@@ -62,8 +70,8 @@
{ {
"name": "closure.lua", "name": "closure.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "transpile: unsupported node",
"ms": 3465 "ms": 5425
}, },
{ {
"name": "code.lua", "name": "code.lua",
@@ -75,7 +83,7 @@
"name": "constructs.lua", "name": "constructs.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "parse error",
"ms": 2522 "ms": 2509
}, },
{ {
"name": "db.lua", "name": "db.lua",
@@ -86,14 +94,14 @@
{ {
"name": "errors.lua", "name": "errors.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 2371 "ms": 2934
}, },
{ {
"name": "events.lua", "name": "events.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "transpile: unsupported node",
"ms": 5133 "ms": 6455
}, },
{ {
"name": "files.lua", "name": "files.lua",
@@ -111,13 +119,13 @@
"name": "literals.lua", "name": "literals.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "parse error",
"ms": 1434 "ms": 1786
}, },
{ {
"name": "locals.lua", "name": "locals.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 1386 "ms": 1554
}, },
{ {
"name": "main.lua", "name": "main.lua",
@@ -129,43 +137,43 @@
"name": "math.lua", "name": "math.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "parse error",
"ms": 2427 "ms": 2378
}, },
{ {
"name": "nextvar.lua", "name": "nextvar.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "transpile: unsupported node",
"ms": 4241 "ms": 5918
}, },
{ {
"name": "pm.lua", "name": "pm.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 5026 "ms": 5658
}, },
{ {
"name": "sort.lua", "name": "sort.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 930 "ms": 1145
}, },
{ {
"name": "strings.lua", "name": "strings.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
"ms": 3424 "ms": 3696
}, },
{ {
"name": "vararg.lua", "name": "vararg.lua",
"status": "fail", "status": "fail",
"reason": "transpile: unsupported node", "reason": "transpile: unsupported node",
"ms": 1931 "ms": 1901
}, },
{ {
"name": "verybig.lua", "name": "verybig.lua",
"status": "fail", "status": "fail",
"reason": "parse error", "reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
"ms": 450 "ms": 533
} }
] ]
} }

View File

@@ -1,13 +1,15 @@
# Lua-on-SX conformance scoreboard # Lua-on-SX conformance scoreboard
**Pass rate:** 0/16 runnable (0.0%) **Pass rate:** 0/16 runnable (0.0%)
fail=16 timeout=0 skip=8 total=24 fail=15 timeout=1 skip=8 total=24
## Top failure modes ## Top failure modes
- **14x** parse error - **6x** transpile: unsupported node
- **1x** undefined symbol: print\ - **4x** other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\
- **1x** transpile: unsupported node - **3x** parse error
- **2x** other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio
- **1x** timeout
## Per-test results ## Per-test results
@@ -15,25 +17,25 @@ fail=16 timeout=0 skip=8 total=24
|---|---|---|---:| |---|---|---|---:|
| all.lua | skip | driver uses dofile to chain other tests | 0 | | all.lua | skip | driver uses dofile to chain other tests | 0 |
| api.lua | skip | requires testC (C debug library) | 0 | | api.lua | skip | requires testC (C debug library) | 0 |
| attrib.lua | fail | parse error | 3243 | | attrib.lua | fail | transpile: unsupported node | 5378 |
| big.lua | fail | undefined symbol: print\ | 4383 | | big.lua | timeout | per-test timeout | 8007 |
| calls.lua | fail | parse error | 3565 | | calls.lua | fail | transpile: unsupported node | 4393 |
| checktable.lua | skip | internal debug helpers | 0 | | checktable.lua | skip | internal debug helpers | 0 |
| closure.lua | fail | parse error | 3465 | | closure.lua | fail | transpile: unsupported node | 5425 |
| code.lua | skip | bytecode inspection via debug library | 0 | | code.lua | skip | bytecode inspection via debug library | 0 |
| constructs.lua | fail | parse error | 2522 | | constructs.lua | fail | parse error | 2509 |
| db.lua | skip | debug library | 0 | | db.lua | skip | debug library | 0 |
| errors.lua | fail | parse error | 2371 | | errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2934 |
| events.lua | fail | parse error | 5133 | | events.lua | fail | transpile: unsupported node | 6455 |
| files.lua | skip | io library | 0 | | files.lua | skip | io library | 0 |
| gc.lua | skip | collectgarbage / finalisers | 0 | | gc.lua | skip | collectgarbage / finalisers | 0 |
| literals.lua | fail | parse error | 1434 | | literals.lua | fail | parse error | 1786 |
| locals.lua | fail | parse error | 1386 | | locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1554 |
| main.lua | skip | standalone interpreter driver | 0 | | main.lua | skip | standalone interpreter driver | 0 |
| math.lua | fail | parse error | 2427 | | math.lua | fail | parse error | 2378 |
| nextvar.lua | fail | parse error | 4241 | | nextvar.lua | fail | transpile: unsupported node | 5918 |
| pm.lua | fail | parse error | 5026 | | pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5658 |
| sort.lua | fail | parse error | 930 | | sort.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1145 |
| strings.lua | fail | parse error | 3424 | | strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3696 |
| vararg.lua | fail | transpile: unsupported node | 1931 | | vararg.lua | fail | transpile: unsupported node | 1901 |
| verybig.lua | fail | parse error | 450 | | verybig.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 533 |

View File

@@ -82,6 +82,7 @@ Each item: implement → tests → tick box → update progress log.
_Newest first. Agent appends on every commit._ _Newest first. Agent appends on every commit._
- 2026-04-24: lua: scoreboard iteration — added `rawget`/`rawset`/`rawequal`/`rawlen`, `loadstring`/`load`, `select`, `assert`, `_G`, `_VERSION`. Failure mix now 6×vararg-transpile / 4×real-assertion / 3×parse / 2×call-non-fn / 1×timeout (was 14 parse + 1 print undef at baseline); tests now reach deep into real assertions. Still 0/16 runnable — next targets: vararg transpile, goto, loadstring-compile depth. 347 unit tests.
- 2026-04-24: lua: `require`/`package` via preload-only (no filesystem search). `package.loaded` caching, nil-returning modules cache as `true`, unknown modules error. 347 tests. - 2026-04-24: lua: `require`/`package` via preload-only (no filesystem search). `package.loaded` caching, nil-returning modules cache as `true`, unknown modules error. 347 tests.
- 2026-04-24: lua: `os` stub — time/clock monotonic counter, difftime, date (default string / `*t` dict), getenv/remove/rename/tmpname/execute/exit stubs. Phase 6 complete. 342 tests. - 2026-04-24: lua: `os` stub — time/clock monotonic counter, difftime, date (default string / `*t` dict), getenv/remove/rename/tmpname/execute/exit stubs. Phase 6 complete. 342 tests.
- 2026-04-24: lua: `io` stub + `print`/`tostring`/`tonumber` globals. io buffers to internal `__io-buffer` (tests drain it via `io.__buffer()`). print: tab-sep + NL. tostring respects `__tostring` metamethod. 334 tests. - 2026-04-24: lua: `io` stub + `print`/`tostring`/`tonumber` globals. io buffers to internal `__io-buffer` (tests drain it via `io.__buffer()`). print: tab-sep + NL. tostring respects `__tostring` metamethod. 334 tests.