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:
parent
7abb116876
commit
9b7d1e436e
56 changed files with 760 additions and 27 deletions
35
test/tests/choice with decorators.ans
Normal file
35
test/tests/choice with decorators.ans
Normal 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
|
||||
7
test/tests/constant variable list.ans
Normal file
7
test/tests/constant variable list.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
::a = *[3]
|
||||
|
||||
|{a}
|
||||
|
||||
a!insert(52)
|
||||
|
||||
|{a}
|
||||
11
test/tests/constrained variable assignement.ans
Normal file
11
test/tests/constrained variable assignement.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
:weigh::is("kg") = 5!type("kg")
|
||||
|
||||
|{weigh}
|
||||
|
||||
weigh = 12!type("kg")
|
||||
|
||||
|{weigh}
|
||||
|
||||
weigh = 32
|
||||
|
||||
|{weigh}
|
||||
7
test/tests/constrained variable definition.ans
Normal file
7
test/tests/constrained variable definition.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:weigh::($(x)x!type=="kg") = type(5, "kg")
|
||||
|
||||
|{weigh}
|
||||
|
||||
:not weigh::($(x)x!type=="kg") = 12
|
||||
|
||||
|{not weigh}
|
||||
29
test/tests/equality operator.ans
Normal file
29
test/tests/equality operator.ans
Normal 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}
|
||||
4
test/tests/exported variable.ans
Normal file
4
test/tests/exported variable.ans
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
:f = $
|
||||
:@x = "ok"
|
||||
|
||||
f.x
|
||||
29
test/tests/function exported.ans
Normal file
29
test/tests/function exported.ans
Normal 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!
|
||||
9
test/tests/function return exit function nested.ans
Normal file
9
test/tests/function return exit function nested.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
:$ hey
|
||||
:@$ foo
|
||||
@2
|
||||
@3
|
||||
@5
|
||||
|u
|
||||
|
||||
|{hey!}
|
||||
|{hey.foo!}
|
||||
7
test/tests/function return nested.ans
Normal file
7
test/tests/function return nested.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:$ hey
|
||||
:@$ foo
|
||||
@2
|
||||
@5
|
||||
|
||||
|{hey!}
|
||||
|{hey.foo!}
|
||||
40
test/tests/function scoped mutable.ans
Normal file
40
test/tests/function scoped mutable.ans
Normal 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!
|
||||
44
test/tests/function scoped nested.ans
Normal file
44
test/tests/function scoped nested.ans
Normal 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!
|
||||
19
test/tests/function scoped recursive.ans
Normal file
19
test/tests/function scoped recursive.ans
Normal 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!
|
||||
29
test/tests/function scoped.ans
Normal file
29
test/tests/function scoped.ans
Normal 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!
|
||||
10
test/tests/function separate variable from variants.ans
Normal file
10
test/tests/function separate variable from variants.ans
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
:$ f
|
||||
:@a = 2
|
||||
|
||||
:$ f(x)
|
||||
:a = 5
|
||||
|
||||
:$ f(b)
|
||||
:a = 10
|
||||
|
||||
|{f.a} = 2
|
||||
13
test/tests/return children.ans
Normal file
13
test/tests/return children.ans
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
:$ fn
|
||||
:i=0
|
||||
@
|
||||
i=50
|
||||
i
|
||||
|
||||
| {fn!} = 50
|
||||
|
||||
:$ g
|
||||
@
|
||||
@3
|
||||
|
||||
| {g!} = 3
|
||||
7
test/tests/tag operator.ans
Normal file
7
test/tests/tag operator.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:$ f
|
||||
@"b"
|
||||
|
||||
|a {5 # |{f!}} c
|
||||
|
||||
2:2 #
|
||||
|a {5 # |{f!}} c
|
||||
8
test/tests/text buffer with tags.ans
Normal file
8
test/tests/text buffer with tags.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
:$ f
|
||||
1 # | lol
|
||||
|
||||
@2 # |d
|
||||
|
||||
:a = |a {f!} {3#|t} b
|
||||
|
||||
@a
|
||||
8
test/tests/text buffer.ans
Normal file
8
test/tests/text buffer.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
:$ f
|
||||
|lol
|
||||
|
||||
@|d
|
||||
|
||||
:a = |a {f!} b
|
||||
|
||||
@a
|
||||
8
test/tests/translate context.ans
Normal file
8
test/tests/translate context.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
| Hello
|
||||
|
||||
"source": "test/tests/translate context.ans:6:1" #
|
||||
| Hello| -> | Bonjour
|
||||
|
||||
| Hello
|
||||
|
||||
| Hello
|
||||
5
test/tests/translate string.ans
Normal file
5
test/tests/translate string.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|{%"Hello"}
|
||||
|
||||
%"Hello" -> "Bonjour"
|
||||
|
||||
|{%"Hello"}
|
||||
5
test/tests/translate text.ans
Normal file
5
test/tests/translate text.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
| Hello
|
||||
|
||||
| Hello| -> | Bonjour
|
||||
|
||||
| Hello
|
||||
Loading…
Add table
Add a link
Reference in a new issue