1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Second test batch and associated fixes

This commit is contained in:
Étienne Fildadut 2023-12-29 17:15:43 +01:00
parent 7abb116876
commit 9b7d1e436e
56 changed files with 760 additions and 27 deletions

View file

@ -0,0 +1,33 @@
--# run #--
--- choice ---
=> | {}"a "|
> | {}"b "|
--- text ---
| {}"-> a"|
--- choice ---
> | {}"a "|
=> | {}"b "|
--- text ---
| {}"-> b"|
--- choice ---
=> | {}"b "|
--- text ---
| {}"-> b"|
--- choice ---
> | {}"a "|
=> | {1:25}"b "|
--- text ---
| {1:25}"-> b"|
--- choice ---
=> | {1:3}"b "|
--- text ---
| {1:3}"-> b"|
--- choice ---
=> | {1:12}"a "|
> | {1:3}"b "|
--- text ---
| {1:12}"-> a"|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"" {}"*[3]" {}""|
--- text ---
| {}"" {}"*[3, 52]" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -1,6 +1,6 @@
--# run #--
--- error ---
./state/State.lua:145: trying to change the value of constant a
trying to change the value of constant a
↳ from test/tests/constant variable.ans:5:3 in assignment: a = 52
↳ from ? in block: ::a = 3…
--# saved #--

View file

@ -0,0 +1,11 @@
--# run #--
--- text ---
| {}"" {}"type(\"kg\", 5)" {}""|
--- text ---
| {}"" {}"type(\"kg\", 12)" {}""|
--- error ---
type check failure for weigh; 32 does not satisfy ($(x) type(x) == t)
↳ from test/tests/constrained variable assignement.ans:9:7 in assignment: weigh = 32
↳ from ? in block: :weigh::is("kg") = type(5, "kg")…
--# saved #--
{}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"" {}"type(\"kg\", 5)" {}""|
--- text ---
| {}"" {}"12" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -1,4 +1,7 @@
--# parse error #--
--# run #--
--- error ---
a is already defined in the current scope
↳ from test/tests/define override function.ans:4:4 in definition: :a = 2
↳ from ? in block: :a = ($() _)…
↳ from ? in block: :a = ($() _)…
--# saved #--
{}

View file

@ -1,5 +1,8 @@
--# parse error #--
--# run #--
--- error ---
can't add an overload variant to non-overloadable variable a defined in the same scope
↳ from test/tests/define override variable.ans:3:1 in definition: :a = ($() _)
↳ from test/tests/define override variable.ans:3:1 in attach block: :a = ($() _)…
↳ from ? in block: :a = 2…
↳ from ? in block: :a = 2…
--# saved #--
{}

View file

@ -1,4 +1,7 @@
--# parse error #--
--# run #--
--- error ---
a is already defined in the current scope
↳ from test/tests/define override.ans:3:4 in definition: :a = 2
↳ from ? in block: :a = 5…
↳ from ? in block: :a = 5…
--# saved #--
{}

View file

@ -0,0 +1,27 @@
--# run #--
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"true = " {}"true" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"true = " {}"true" {}""|
--- text ---
| {}"false = " {}"false" {}""|
--- text ---
| {}"true = " {}"true" {}""|
--- text ---
| {}"true = " {}"true" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,5 @@
--# run #--
--- return ---
"ok"
--# saved #--
{}

View file

@ -1,6 +1,6 @@
--# run #--
--- error ---
./state/State.lua:145: can't call closure ($(a, b) _): expected 2 arguments, received 1
can't call closure ($(a, b) _): expected 2 arguments, received 1
↳ from test/tests/function args arity check fail.ans:4:2 in call: f("ok")
↳ from ? in block: :f = ($(a, b) _)…
--# saved #--

View file

@ -0,0 +1,21 @@
--# run #--
--- text ---
| {}"local:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"exported:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"2" {}""|
--- text ---
| {}"" {}"3" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,8 @@
--# run #--
--- text ---
| {}"" {}"5" {}""|
| {}"" {}"2" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,8 @@
--# run #--
--- text ---
| {}"" {}"5" {}""|
| {}"" {}"2" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -1,6 +1,6 @@
--# run #--
--- error ---
./state/State.lua:145: identifier "b" is undefined in branch 0a138a38-3faa-4478-10f6f-1a9de1e0a8e1
identifier "b" is undefined in branch 0a138a38-3faa-4478-10f6f-1a9de1e0a8e1
↳ from test/tests/function scope wrong.ans:4:7 in identifier: b
↳ from test/tests/function scope wrong.ans:4:1 in text interpolation: | a: {b}|
↳ from test/tests/function scope wrong.ans:4:1 in translatable: | a: {b}|

View file

@ -0,0 +1,65 @@
--# run #--
--- text ---
| {}"new list each time:"|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"1" {}": " {}"*[1]" {}""|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"2" {}": " {}"*[2]" {}""|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"3" {}": " {}"*[3]" {}""|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"4" {}": " {}"*[4]" {}""|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"5" {}": " {}"*[5]" {}""|
--- text ---
| {}"after recursion " {}"4" {}": " {}"*[4]" {}""|
--- text ---
| {}"after recursion " {}"3" {}": " {}"*[3]" {}""|
--- text ---
| {}"after recursion " {}"2" {}": " {}"*[2]" {}""|
--- text ---
| {}"after recursion " {}"1" {}": " {}"*[1]" {}""|
--- text ---
| {}"pass list:"|
--- text ---
| {}"start: " {}"*[]" {}""|
--- text ---
| {}"before recursion " {}"1" {}": " {}"*[1]" {}""|
--- text ---
| {}"start: " {}"*[1]" {}""|
--- text ---
| {}"before recursion " {}"2" {}": " {}"*[1, 2]" {}""|
--- text ---
| {}"start: " {}"*[1, 2]" {}""|
--- text ---
| {}"before recursion " {}"3" {}": " {}"*[1, 2, 3]" {}""|
--- text ---
| {}"start: " {}"*[1, 2, 3]" {}""|
--- text ---
| {}"before recursion " {}"4" {}": " {}"*[1, 2, 3, 4]" {}""|
--- text ---
| {}"start: " {}"*[1, 2, 3, 4]" {}""|
--- text ---
| {}"before recursion " {}"5" {}": " {}"*[1, 2, 3, 4, 5]" {}""|
--- text ---
| {}"after recursion " {}"4" {}": " {}"*[1, 2, 3, 4, 5]" {}""|
--- text ---
| {}"after recursion " {}"3" {}": " {}"*[1, 2, 3, 4, 5]" {}""|
--- text ---
| {}"after recursion " {}"2" {}": " {}"*[1, 2, 3, 4, 5]" {}""|
--- text ---
| {}"after recursion " {}"1" {}": " {}"*[1, 2, 3, 4, 5]" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,61 @@
--# run #--
--- text ---
| {}"depth 1:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, unscoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, scoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, unscoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, scoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, unscoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}">" {}" depth 2, scoped:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,33 @@
--# run #--
--- text ---
| {}"start: " {}"1" {}""|
--- text ---
| {}"before recursion " {}"1" {}": " {}"2" {}""|
--- text ---
| {}"start: " {}"1" {}""|
--- text ---
| {}"before recursion " {}"2" {}": " {}"2" {}""|
--- text ---
| {}"start: " {}"1" {}""|
--- text ---
| {}"before recursion " {}"3" {}": " {}"2" {}""|
--- text ---
| {}"start: " {}"1" {}""|
--- text ---
| {}"before recursion " {}"4" {}": " {}"2" {}""|
--- text ---
| {}"start: " {}"1" {}""|
--- text ---
| {}"before recursion " {}"5" {}": " {}"2" {}""|
--- text ---
| {}"after recursion " {}"4" {}": " {}"2" {}""|
--- text ---
| {}"after recursion " {}"3" {}": " {}"2" {}""|
--- text ---
| {}"after recursion " {}"2" {}": " {}"2" {}""|
--- text ---
| {}"after recursion " {}"1" {}": " {}"2" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,21 @@
--# run #--
--- text ---
| {}"paren:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"no paren:"|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- text ---
| {}"" {}"1" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,12 @@
--# run #--
--- error ---
can't call overload overload<($(c::($(x) <lua function>), s::($(x) <lua function>)) = v; <lua function>), ($(c::($(x) <lua function>), s::($(x) <lua function>)) = v; <lua function>), ($(c::($(x) <lua function>), s::($(x) <lua function>)) <lua function>)>: no function match (overload<($(b) _), ($(x) _), ($() _)>, "a"), possible functions were:
• (c::($(x) <lua function>), s::($(x) <lua function>)) = v: expected 3 arguments, received 2
• (c::($(x) <lua function>), s::($(x) <lua function>)) = v: expected 3 arguments, received 2
• (c::($(x) <lua function>), s::($(x) <lua function>)): type check failure for parameter c in function (c::($(x) <lua function>), s::($(x) <lua function>))
↳ from test/tests/function separate variable from variants.ans:10:4 in call: f . "a"
↳ from test/tests/function separate variable from variants.ans:10:1 in text interpolation: | {(f . "a")} = 2|
↳ from test/tests/function separate variable from variants.ans:10:1 in translatable: | {(f . "a")} = 2|
↳ from ? in block: :f = ($() _)…
--# saved #--
{}

View file

@ -1,6 +1,6 @@
--# run #--
--- error ---
./state/State.lua:145: can't call overload overload<($(a::($(x) <lua function>)) _), ($(x::($(x) <lua function>)) _)>: more than one function match (5), matching functions were at least (specificity 1.3):
can't call overload overload<($(a::($(x) <lua function>)) _), ($(x::($(x) <lua function>)) _)>: more than one function match (5), matching functions were at least (specificity 1.3):
• (x::($(x) <lua function>))
• (a::($(x) <lua function>))
↳ from test/tests/function type dispatch ambigous.ans:7:3 in call: fn(5)

View file

@ -10,7 +10,7 @@
--- text ---
| {}"" {}"*[3, 12, 99]" {}""|
--- error ---
./state/State.lua:145: list index out of bounds
list index out of bounds
↳ from test/tests/list assignement.ans:21:6 in call: x(5) = 0
↳ from ? in block: :x = *[1, 2]…
--# saved #--

View file

@ -8,7 +8,7 @@
--- text ---
| {}"" {}"3" {}" == " {}"3" {}""|
--- error ---
./state/State.lua:145: tuple index out of bounds
tuple index out of bounds
↳ from test/tests/list index.ans:11:4 in call: x(-4)
↳ from test/tests/list index.ans:11:1 in text interpolation: | {x(-4)}|
↳ from test/tests/list index.ans:11:1 in translatable: | {x(-4)}|

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"" {}"50" {}" = 50"|
--- text ---
| {}"" {}"3" {}" = 3"|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"a " {1:5}"" {1:5}"b" {1:5}"" {}" c"|
--- text ---
| {2:2}"a " {1:5, 2:2}"" {1:5, 2:2}"b" {1:5, 2:2}"" {2:2}" c"|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,7 @@
--# run #--
--- text ---
| {1:1}"lol"|
--- return ---
@| {}"a " {1:2}"d" {}" " {1:3}"t" {}" b"|
--# saved #--
{}

View file

@ -0,0 +1,7 @@
--# run #--
--- text ---
| {}"lol"|
--- return ---
@| {}"a " {}"d" {}" b"|
--# saved #--
{}

View file

@ -0,0 +1,11 @@
--# run #--
--- text ---
| {}"Hello"|
--- text ---
| {}"Bonjour"|
--- text ---
| {}"Hello"|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"" {}"Hello" {}""|
--- text ---
| {}"" {}"Bonjour" {}""|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"Hello"|
--- text ---
| {}"Bonjour"|
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,35 @@
1 ~ | a |>
| -> a
| b |>
| -> b
:@choice = 1
1 ~ | a |>
| -> a
| b |>
| -> b
choice = 2
() ~ | a |>
| -> a
| b |>
| -> b
choice = 1
| a |>
| -> a
25 # | b |>
| -> b
choice = 2
12 # () ~ | a |>
| -> a
3 # | b |>
| -> b
choice = 1
12 # 1 ~ | a |>
| -> a
3 # | b |>
| -> b
choice = 1

View file

@ -0,0 +1,7 @@
::a = *[3]
|{a}
a!insert(52)
|{a}

View file

@ -0,0 +1,11 @@
:weigh::is("kg") = 5!type("kg")
|{weigh}
weigh = 12!type("kg")
|{weigh}
weigh = 32
|{weigh}

View file

@ -0,0 +1,7 @@
:weigh::($(x)x!type=="kg") = type(5, "kg")
|{weigh}
:not weigh::($(x)x!type=="kg") = 12
|{not weigh}

View file

@ -0,0 +1,29 @@
::a = [1:2]
|false = {a == [5:2]}
|false = {a == [1:3]}
|true = {a == [1:2]}
::b = [1,2,3]
|false = {b == a}
|false = {b == []}
|false = {b == [3,1,2]}
|false = {b == [1,2,3,4]}
|true = {b == [1,2,3]}
:c = *[1,2,3]
|false = {c == b}
|true = {c!to tuple == b}
::d = [1,2,3]
|true = {d == b}

View file

@ -0,0 +1,4 @@
:f = $
:@x = "ok"
f.x

View file

@ -0,0 +1,29 @@
:$ f
:a = 1
|{a}
a = a + 1
:$ g
:@a = 1
|{a}
a = a + 1
|local:
f!
f!
f!
|exported:
g!
g!
g!

View file

@ -0,0 +1,9 @@
:$ hey
:@$ foo
@2
@3
@5
|u
|{hey!}
|{hey.foo!}

View file

@ -0,0 +1,7 @@
:$ hey
:@$ foo
@2
@5
|{hey!}
|{hey.foo!}

View file

@ -0,0 +1,40 @@
:n = 0
:$ f(c=1)
:a = *[]
|start: {a}
a!insert(c)
n += 1
|before recursion {c}: {a}
n < 5 ~
f(c+1)
|after recursion {c}: {a}
|new list each time:
f!
:$ g(c=1, a=*[])
|start: {a}
a!insert(c)
n += 1
|before recursion {c}: {a}
n < 5 ~
g(c+1, a)
|after recursion {c}: {a}
|pass list:
n = 0
g!

View file

@ -0,0 +1,44 @@
:$ f()
:a = 1
|{a}
a = a + 1
:$ g
:a = 1
|{a}
a = a + 1
:$ h()
:a = 1
|{a}
a = a + 1
|\> depth 2, unscoped:
g!
g!
g!
|\> depth 2, scoped:
h!
h!
h!
|depth 1:
f!
f!
f!

View file

@ -0,0 +1,19 @@
:n = 0
:$ f(c=1)
:a = 1
|start: {a}
a = a + 1
n += 1
|before recursion {c}: {a}
n < 5 ~
f(c+1)
|after recursion {c}: {a}
f!

View file

@ -0,0 +1,29 @@
:$ f()
:a = 1
|{a}
a = a + 1
:$ g
:a = 1
|{a}
a = a + 1
|paren:
f!
f!
f!
|no paren:
g!
g!
g!

View file

@ -0,0 +1,10 @@
:$ f
:@a = 2
:$ f(x)
:a = 5
:$ f(b)
:a = 10
|{f.a} = 2

View file

@ -0,0 +1,13 @@
:$ fn
:i=0
@
i=50
i
| {fn!} = 50
:$ g
@
@3
| {g!} = 3

View file

@ -0,0 +1,7 @@
:$ f
@"b"
|a {5 # |{f!}} c
2:2 #
|a {5 # |{f!}} c

View file

@ -0,0 +1,8 @@
:$ f
1 # | lol
@2 # |d
:a = |a {f!} {3#|t} b
@a

View file

@ -0,0 +1,8 @@
:$ f
|lol
@|d
:a = |a {f!} b
@a

View file

@ -0,0 +1,8 @@
| Hello
"source": "test/tests/translate context.ans:6:1" #
| Hello| -> | Bonjour
| Hello
| Hello

View file

@ -0,0 +1,5 @@
|{%"Hello"}
%"Hello" -> "Bonjour"
|{%"Hello"}

View file

@ -0,0 +1,5 @@
| Hello
| Hello| -> | Bonjour
| Hello