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,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