lua: math fns type-check args (math.sin() now errors instead of returning 0)
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:
@@ -1215,19 +1215,27 @@
|
||||
(define lua-math-pi 3.141592653589793)
|
||||
(define lua-math-huge (/ 1.0 0.0))
|
||||
|
||||
(define lua-math-abs (fn (x) (abs x)))
|
||||
(define lua-math-ceil (fn (x) (ceil x)))
|
||||
(define lua-math-floor (fn (x) (floor x)))
|
||||
(define lua-math-sqrt (fn (x) (sqrt x)))
|
||||
(define lua-math-exp (fn (x) (exp x)))
|
||||
(define lua-math-sin (fn (x) (sin x)))
|
||||
(define lua-math-cos (fn (x) (cos x)))
|
||||
(define lua-math-tan (fn (x) (tan x)))
|
||||
(define lua-math-asin (fn (x) (asin x)))
|
||||
(define lua-math-acos (fn (x) (acos x)))
|
||||
(define lua-math-atan (fn (x) (atan x)))
|
||||
(define lua-math-atan2 (fn (y x) (atan2 y x)))
|
||||
(define lua-math-pow (fn (a b) (pow a b)))
|
||||
(define
|
||||
lua-math-num
|
||||
(fn (name x)
|
||||
(let ((n (lua-to-number x)))
|
||||
(cond
|
||||
((= n nil) (error (str "bad argument to '" name "' (number expected)")))
|
||||
(else n)))))
|
||||
|
||||
(define lua-math-abs (fn (x) (abs (lua-math-num "abs" x))))
|
||||
(define lua-math-ceil (fn (x) (ceil (lua-math-num "ceil" x))))
|
||||
(define lua-math-floor (fn (x) (floor (lua-math-num "floor" x))))
|
||||
(define lua-math-sqrt (fn (x) (sqrt (lua-math-num "sqrt" x))))
|
||||
(define lua-math-exp (fn (x) (exp (lua-math-num "exp" x))))
|
||||
(define lua-math-sin (fn (x) (sin (lua-math-num "sin" x))))
|
||||
(define lua-math-cos (fn (x) (cos (lua-math-num "cos" x))))
|
||||
(define lua-math-tan (fn (x) (tan (lua-math-num "tan" x))))
|
||||
(define lua-math-asin (fn (x) (asin (lua-math-num "asin" x))))
|
||||
(define lua-math-acos (fn (x) (acos (lua-math-num "acos" x))))
|
||||
(define lua-math-atan (fn (x) (atan (lua-math-num "atan" x))))
|
||||
(define lua-math-atan2 (fn (y x) (atan2 (lua-math-num "atan2" y) (lua-math-num "atan2" x))))
|
||||
(define lua-math-pow (fn (a b) (pow (lua-math-num "pow" a) (lua-math-num "pow" b))))
|
||||
|
||||
(define lua-math-log
|
||||
(fn (&rest args)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"totals": {
|
||||
"pass": 1,
|
||||
"fail": 8,
|
||||
"timeout": 7,
|
||||
"fail": 12,
|
||||
"timeout": 3,
|
||||
"skip": 8,
|
||||
"total": 24,
|
||||
"runnable": 16,
|
||||
@@ -10,12 +10,12 @@
|
||||
},
|
||||
"top_failure_modes": [
|
||||
[
|
||||
"timeout",
|
||||
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
7
|
||||
],
|
||||
[
|
||||
"other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
4
|
||||
"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": 6895
|
||||
"ms": 6525
|
||||
},
|
||||
{
|
||||
"name": "big.lua",
|
||||
@@ -59,7 +63,7 @@
|
||||
"name": "calls.lua",
|
||||
"status": "fail",
|
||||
"reason": "undefined symbol: fat\\",
|
||||
"ms": 5736
|
||||
"ms": 5092
|
||||
},
|
||||
{
|
||||
"name": "checktable.lua",
|
||||
@@ -71,7 +75,7 @@
|
||||
"name": "closure.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8007
|
||||
"ms": 8006
|
||||
},
|
||||
{
|
||||
"name": "code.lua",
|
||||
@@ -81,9 +85,9 @@
|
||||
},
|
||||
{
|
||||
"name": "constructs.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8008
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to compare incompat",
|
||||
"ms": 6780
|
||||
},
|
||||
{
|
||||
"name": "db.lua",
|
||||
@@ -95,13 +99,13 @@
|
||||
"name": "errors.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 3826
|
||||
"ms": 3208
|
||||
},
|
||||
{
|
||||
"name": "events.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8007
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 7307
|
||||
},
|
||||
{
|
||||
"name": "files.lua",
|
||||
@@ -119,13 +123,13 @@
|
||||
"name": "literals.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 2748
|
||||
"ms": 1816
|
||||
},
|
||||
{
|
||||
"name": "locals.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||
"ms": 2339
|
||||
"ms": 1627
|
||||
},
|
||||
{
|
||||
"name": "main.lua",
|
||||
@@ -137,43 +141,43 @@
|
||||
"name": "math.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"lua: attempt to call non-functio",
|
||||
"ms": 6042
|
||||
"ms": 4156
|
||||
},
|
||||
{
|
||||
"name": "nextvar.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8007
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 7064
|
||||
},
|
||||
{
|
||||
"name": "pm.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8010
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 5813
|
||||
},
|
||||
{
|
||||
"name": "sort.lua",
|
||||
"status": "timeout",
|
||||
"reason": "per-test timeout",
|
||||
"ms": 8007
|
||||
"ms": 8008
|
||||
},
|
||||
{
|
||||
"name": "strings.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 6167
|
||||
"ms": 3987
|
||||
},
|
||||
{
|
||||
"name": "vararg.lua",
|
||||
"status": "fail",
|
||||
"reason": "other: Unhandled exception: \\\"Unhandled exception: \\\\\\\"assertion failed!\\\\\\\"\\",
|
||||
"ms": 3432
|
||||
"ms": 2243
|
||||
},
|
||||
{
|
||||
"name": "verybig.lua",
|
||||
"status": "pass",
|
||||
"reason": "",
|
||||
"ms": 1659
|
||||
"ms": 1085
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,15 +1,16 @@
|
||||
# Lua-on-SX conformance scoreboard
|
||||
|
||||
**Pass rate:** 1/16 runnable (6.2%)
|
||||
fail=8 timeout=7 skip=8 total=24
|
||||
fail=12 timeout=3 skip=8 total=24
|
||||
|
||||
## Top failure modes
|
||||
|
||||
- **7x** timeout
|
||||
- **4x** 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=8 timeout=7 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\\\"\ | 6895 |
|
||||
| attrib.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: module 'C' not found\\\"\ | 6525 |
|
||||
| big.lua | timeout | per-test timeout | 8007 |
|
||||
| calls.lua | fail | undefined symbol: fat\ | 5736 |
|
||||
| calls.lua | fail | undefined symbol: fat\ | 5092 |
|
||||
| checktable.lua | skip | internal debug helpers | 0 |
|
||||
| closure.lua | timeout | per-test timeout | 8007 |
|
||||
| closure.lua | timeout | per-test timeout | 8006 |
|
||||
| code.lua | skip | bytecode inspection via debug library | 0 |
|
||||
| constructs.lua | timeout | per-test timeout | 8008 |
|
||||
| constructs.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to compare incompat | 6780 |
|
||||
| db.lua | skip | debug library | 0 |
|
||||
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3826 |
|
||||
| events.lua | timeout | per-test timeout | 8007 |
|
||||
| errors.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3208 |
|
||||
| events.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7307 |
|
||||
| files.lua | skip | io library | 0 |
|
||||
| gc.lua | skip | collectgarbage / finalisers | 0 |
|
||||
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2748 |
|
||||
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 2339 |
|
||||
| literals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 1816 |
|
||||
| locals.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 1627 |
|
||||
| main.lua | skip | standalone interpreter driver | 0 |
|
||||
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 6042 |
|
||||
| nextvar.lua | timeout | per-test timeout | 8007 |
|
||||
| pm.lua | timeout | per-test timeout | 8010 |
|
||||
| sort.lua | timeout | per-test timeout | 8007 |
|
||||
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 6167 |
|
||||
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3432 |
|
||||
| verybig.lua | pass | - | 1659 |
|
||||
| math.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"lua: attempt to call non-functio | 4156 |
|
||||
| nextvar.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 7064 |
|
||||
| pm.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 5813 |
|
||||
| sort.lua | timeout | per-test timeout | 8008 |
|
||||
| strings.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 3987 |
|
||||
| vararg.lua | fail | other: Unhandled exception: \"Unhandled exception: \\\"assertion failed!\\\"\ | 2243 |
|
||||
| verybig.lua | pass | - | 1085 |
|
||||
|
||||
@@ -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 fns now error on bad/missing args (was silently returning 0). New `lua-math-num "name" x` validator wraps `abs`/`ceil`/`floor`/`sqrt`/`exp`/`sin`/`cos`/`tan`/`asin`/`acos`/`atan`/`atan2`/`pow`. errors.lua moves past assert #4 (`pcall(math.sin)` now returns false+err as expected).
|
||||
- 2026-04-24: lua: scoreboard iteration — **pattern character sets** `[...]` and `[^...]`. New `lua-pat-set-end`/`lua-pat-set-match` helpers handle ranges (`[a-z]`), classes inside sets (`[%d%a]`), negation (`[^abc]`), and `[]...]`/`[^]...]` (literal `]` as first char). Asserts 6→4, but timeouts 3→7 — many tests now reach loop-heavy code. 387/387 green (+3 charset tests).
|
||||
- 2026-04-24: lua: scoreboard iteration — `tonumber(s, base)` for bases 2-36. Validates digit ranges per base, supports leading `+`/`-`, trims whitespace. `math.lua` past assert #21. Asserts 8→6, timeouts 3→4. 384/384 green.
|
||||
- 2026-04-24: lua: scoreboard iteration — added `lua-unwrap-final-return` (post-processor that rewrites top-level `(raise (list 'lua-ret V))` → `V` so top-level defines leak to SX top and loadstring closures can see them). Tried dropping the function-guard at top level, but too many tests use `if x then return 0 else return err end` at chunk tail, whose returns aren't at the *statement-list* tail — guard still needed. Kept guard + unwrap-as-no-op. Scoreboard unchanged.
|
||||
|
||||
Reference in New Issue
Block a user