Files
rose-ash/lib/lua/tests/eval.sx
giles 99753580b4 Recover agent-loop progress: lua/prolog/forth/erlang/haskell phases 1-2
Salvaged from worktree-agent-* branches killed during sx-tree MCP outage:
- lua: tokenizer + parser + phase-2 transpile (~157 tests)
- prolog: tokenizer + parser + unification (72 tests, plan update lost to WIP)
- forth: phase-1 reader/interpreter + phase-2 colon/VARIABLE (134 tests)
- erlang: tokenizer + parser (114 tests)
- haskell: tokenizer + parse tests (43 tests)

Cherry-picked file contents only, not branch history, to avoid pulling in
unrelated ocaml-vm merge commits that were in those branches' bases.
2026-04-24 16:03:00 +00:00

31 lines
1.3 KiB
Plaintext

(define
lua-eval-tests
(list
(list "arith-add" "return 1 + 2" 3)
(list "arith-sub" "return 10 - 3" 7)
(list "arith-mul" "return 4 * 5" 20)
(list "arith-prec" "return 1 + 2 * 3" 7)
(list "arith-paren" "return (1 + 2) * 3" 9)
(list "unary-neg" "return -5 + 10" 5)
(list "lt" "return 1 < 2" true)
(list "eq" "return 2 == 2" true)
(list "neq" "return 1 ~= 2" true)
(list "and-value" "return true and 42" 42)
(list "or-value" "return false or 99" 99)
(list "or-nil" "return nil or 7" 7)
(list "and-short" "return false and 999" false)
(list "not-true" "return not true" false)
(list "not-zero" "return not 0" false)
(list "local" "local x = 5 return x * 2" 10)
(list "local-mutate" "local x=0 x=x+1 x=x+1 return x" 2)
(list "local-multi" "local a,b = 1,2 return a + b" 3)
(list "for-sum" "local sum=0 for i=1,5 do sum=sum+i end return sum" 15)
(list "for-neg-step" "local n=0 for i=10,1,-1 do n=n+1 end return n" 10)
(list "while" "local i=0 while i<5 do i=i+1 end return i" 5)
(list "repeat" "local i=0 repeat i=i+1 until i>=3 return i" 3)
(list "for-big" "local s=0 for i=1,100 do s=s+i end return s" 5050)
(list
"nested-for"
"local s=0 for i=1,3 do for j=1,3 do s=s+1 end end return s"
9)))