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

First test batch and associated fixes

The test runner is also nicer to use.
This commit is contained in:
Étienne Fildadut 2023-12-28 16:51:18 +01:00
parent 10084dec23
commit 82ce53be83
154 changed files with 1586 additions and 78 deletions

View file

@ -0,0 +1,11 @@
:$ a - b
@"generic minus"
:$ a::string - b::string
@a + " minus " + b
| {2-5}
| {"heh"-"lol"}
| {[]-[]}

View file

@ -0,0 +1,7 @@
:c = 1
|{c}
c += 2
|{c}

View file

@ -0,0 +1,11 @@
:@choice = 2
| ye |>
| no
| ne |>
| ok
choice = 1
| ho |>
| plop
| oh |>
| plup

View file

@ -0,0 +1,11 @@
:$ f
| neol |>
| nah
| ho |>
|plop
f!
| oh |>
|ok
f!
:@choice=3

View file

@ -0,0 +1,11 @@
:@choice=1
:$ jump button
1 # |A
| Suprise choice! |> ()
@"JOIN"
| Press {jump button!} to jump. |>
|ok
| No |>
|ko

View file

@ -0,0 +1,11 @@
:@choice=1
:$ jump button
1 # | a
@"SPLIT"
| Press {jump button!} to jump. |>
| ok
| No |>
| ko

View file

@ -0,0 +1,17 @@
:$ jump button
@1 # | A
:$ move axis
1 # | left
@" joystick"
| Press {jump button!} to jump. |>
|ok
| No |>
|ko
:@choice = 1
| Other |>
|ok
| Use {move axis!} to move. |>
|ko

View file

@ -0,0 +1,16 @@
:choice = 1
:$ f
42 #
| a |>
| b
f!
| c |> ()
"k":"v" #
f!
| d |> ()
| e
| f

View file

@ -0,0 +1,5 @@
| ye |>
| no
| ne |>
| ok
:@choice = 2

12
test/tests/closure.ans Normal file
View file

@ -0,0 +1,12 @@
:$ f(x)
$(y) x + y
:add two = f(2)
:add five = f(5)
|{add two(3)} = 5
|{add five(3)} = 8
|{add two(2)} = 4
|{add five(2)} = 7

9
test/tests/comment.ans Normal file
View file

@ -0,0 +1,9 @@
((hey couic + 5))
((nested ((comments)) d))
2 ((end of line))
((start of line)) 3
5 + ((middle)) 3

View file

@ -0,0 +1,3 @@
() ~ |ko
1 ~ |ok
1 ~ |ok bis

View file

@ -0,0 +1,6 @@
:a = 5
a == 2 ~
|ko
~
|ok

View file

@ -0,0 +1,6 @@
:a = 5
a == 5 ~
|ok
~
|ko

View file

@ -0,0 +1,8 @@
:a = 5
a == 2 ~
|ko
~ () ~
|ko
~
|ok

View file

@ -0,0 +1,8 @@
:a = 5
a == 2 ~
|ko
~ 1 ~
|ok
~
|ko

View file

@ -0,0 +1,4 @@
:a = 5
a == 2 ~
|ko

View file

@ -0,0 +1,6 @@
:$ f
@|b
|a {5 ~ f!} c
|a {() ~ f!} c

View file

@ -0,0 +1,4 @@
:a = 5
a == 5 ~
|ok

View file

@ -0,0 +1,7 @@
::a = 3
{a}
a = 52
{a}

View file

@ -0,0 +1,12 @@
:person = "personne"
:$ format(p::is(person))
p = p!value
@"Name: {p("name")}\nAge: {p("age")}"
:$ Person(name, age)
@{"name":name, "age":age}!type(person)
:abject = Person("Darmanin", 38)
|{abject}

View file

@ -0,0 +1,4 @@
:$ a
()
:a = 2

View file

@ -0,0 +1,4 @@
:a = 2
:$ a
()

View file

@ -0,0 +1,5 @@
:a = 5
:a = 2
a: {a}

1
test/tests/define.ans Normal file
View file

@ -0,0 +1 @@
:a = 5

7
test/tests/flush.ans Normal file
View file

@ -0,0 +1,7 @@
:@choice = 1
| a
| b |> ()
| c
| d |> ()

View file

@ -0,0 +1,4 @@
:$ f(a)
|{a}
f("ok")

View file

@ -0,0 +1,4 @@
:$ f(a, b)
| {a}{b}
f("ok")

View file

@ -0,0 +1,4 @@
:$ f(a, b)
| {a}{b}
f("o", "k")

View file

@ -0,0 +1,22 @@
:a = 5
:$ f(p)
@a
:$ f(p) = v
|v={v}
a = v
:$ f(p) = v::string
|v2={v}
a = p
|{f(a)}
f(3) = 50
|{f(a)}
f(3) = "ok"
|{f(a)}

View file

@ -0,0 +1,21 @@
:f = $(x)x*x
:$g(x)
@x*x
|{f(5)} = {g(5)}
|{f(2)} = {g(2)}
:y = 5
:h = $(x)x*x+y
| {h(3)} == 14
y = 7
| {h(5)} == 32
:i = $y*y
| {i!} == 49

View file

@ -0,0 +1,9 @@
:$ fn(x)
|x
:$ fn(a)
|a
fn(a=5)
fn(x=5)

View file

@ -0,0 +1,8 @@
:$ f(a, b)
()
:$ f(x)
()
:$ f(u, v)
()

View file

@ -0,0 +1,6 @@
:$ hey
@5
|a
@2
|{hey!}

View file

@ -0,0 +1,4 @@
:$ hey
@5
|{hey!}

View file

@ -0,0 +1,4 @@
:$ a
:b = 5
| a: {b}

View file

@ -0,0 +1,4 @@
:$ a
:@b = 5
|a: {a.b}

View file

@ -0,0 +1,12 @@
:$ a(x::number)
@x + 2
:$ x
:$ a(x::string)
@x + "heh"
|{a("plop")}
|{a(2)}
x!

View file

@ -0,0 +1,7 @@
:$ fn(x::number)
|x
:$ fn(a::number)
|a
fn(5)

View file

@ -0,0 +1,9 @@
:$ fn(x::number)
|x
:$ fn(a::string)
|a
fn("s")
fn(5)

View file

@ -0,0 +1,6 @@
:$ f(a)
|{a}
"ok"!f
"ok"!f()

View file

@ -0,0 +1,4 @@
:$ f(a, b)
|{a}{b}
"o"!f("k")

9
test/tests/function.ans Normal file
View file

@ -0,0 +1,9 @@
:$ f
|ok
f!
:g = $
|ok2
g!

View file

@ -0,0 +1,12 @@
:x = 4
:pi=3.14
|{2x} = 8
|{(2+1)x} = 12
|{2pi} = 2pi
|{1/2x} = 0.125
|{(1/2)x+.1} = 2.1

View file

@ -0,0 +1,23 @@
:$ a
|a
@1
:$ b
|b
@()
|{a! & b!} = a b ()
|{b! & a!} = b ()
|{a! & a!} = a a 1
|{b! & b!} = b ()
|{a! | b!} = a 1
|{b! | a!} = b a 1
|{a! | a!} = a 1
|{b! | b!} = b b ()

View file

@ -0,0 +1,21 @@
:x = *[1,2]
|{x}
x(1) = 3
|{x}
x(2) = 5
|{x}
x(-1) = 12
|{x}
x(3) = 99
|{x}
x(5) = 0

11
test/tests/list index.ans Normal file
View file

@ -0,0 +1,11 @@
:x = [1,2,3]
|{x}
|{x(1)} == {x(-3)}
|{x(2)} == {x(-2)}
|{x(3)} == {x(-1)}
|{x(-4)}

View file

@ -0,0 +1,5 @@
:i = 0
(i += 1; i <= 10) ~? (| {i}\n)!
|{i}

View file

@ -0,0 +1,20 @@
:x = *{1,2}
|{x}
|{x(1) = 3}
|{x}
|{x("foo") = "a"}
|{x}
|{x("bar") = "b"}
|{x}
|{x("foo") = "c"}
|{x}

7
test/tests/map index.ans Normal file
View file

@ -0,0 +1,7 @@
:t = {"ahah":23,"k":23,12}
|{t} == \{3=12, ahah=23, k=23}
|{t(3)} == 12
|{t("ahah")} == 23

View file

@ -0,0 +1,4 @@
:$ f(a, b, c)
@a + b + c
|{f("a", "b", "c")} = {f(a="a", b="b", c="c")} = {f(c="c", a="a", b="b")}

View file

@ -0,0 +1,6 @@
:$ f
:@x = 5
:a = f
|{a.("x")}

View file

@ -0,0 +1,19 @@
1 ~
|yes
() ~
|no
~
|nope
1 ~
|niet
() ~
|still no
~
|nein
() ~
|nah
~
|ye
~
|da

View file

@ -0,0 +1,18 @@
1 ~
|a
|b
1 ~
|c
|d
1 ~
|e
| f |> ()
:@choice = 1
1 ~
|g
| h |> ()

View file

@ -0,0 +1,4 @@
:$ f(a, b, c="c")
@a + b + c
|{f("a", "b")} = {f("a", "b", "c")} = {f(b="b", a="a")}

View file

@ -0,0 +1,5 @@
:name = "test"
|{[name:1, 3:"p", (name):"foo", "ho":"ah", name:name]}
|{["name":1, 3:"p", name:"foo", "ho":"ah", "name":name]}

View file

@ -0,0 +1,10 @@
:$ f
| a |>
| x
@1
| y
@2
f! == 2 ~
:@choice = 1
| Yes.

View file

@ -0,0 +1,7 @@
|expression {"{"a"}"}
|quote {"\""}
|other codes {"\n"} {"\\"} {"\t"} \{braces}
|{"escaping expressions {"a"+"bc"} and \{stuff} \\ and quotes \""}

View file

@ -0,0 +1,4 @@
1 #
|foo
1 ~ "b":[1,2] #
1 ~ "a":[2,3] # | bar

View file

@ -0,0 +1,3 @@
1 #
| foo
"a":[2,3] # | bar

4
test/tests/tag empty.ans Normal file
View file

@ -0,0 +1,4 @@
1 #
|foo
() #
|bar

4
test/tests/tag.ans Normal file
View file

@ -0,0 +1,4 @@
1 #
|foo
"a":[2,3] #
|bar

View file

@ -0,0 +1,5 @@
| a
| b c
|a
|b c

View file

@ -0,0 +1,3 @@
|a
|b c

View file

@ -0,0 +1,9 @@
|expression \{a}
|quote \"
|other codes \n \\ \t
|decorators \# tag \~ condition \$ fn
|sub \[text]

View file

@ -0,0 +1,3 @@
:a = 5
|a: {a}

View file

@ -0,0 +1,16 @@
:choice = 1
:$ jump button
1 # | A
| Surprise choice! |>
| ok
:$ move axis
1 # | left
| Surprise choice! |>
| ok2
@" joystick"
| Press {jump button!} to jump.
| Use {move axis!} to move.

View file

@ -0,0 +1,13 @@
:$ jump button
1 # | A
@
:$ move axis
1 # | left
@" joystick"
| Press {jump button!} to jump.
| Use {move axis!} to move.

View file

@ -0,0 +1,10 @@
:$ jump button
@1 # | A
:$ move axis
2 # | left
@" joystick"
| Press {jump button!} to jump.
| Use {move axis!} to move.

1
test/tests/text.ans Normal file
View file

@ -0,0 +1 @@
|a

View file

@ -0,0 +1,11 @@
:$ -f
@"generic minus"
:$ -f::string
@"minus "+f
|{-5}
|{-"lol"}
|{-[]}

View file

@ -0,0 +1,19 @@
:i = 1
| Start with i={i}:
i < 5 ~?
| {i}
i += 1
~
| Loop not ran.
| Start with i={i}:
i < 5 ~?
| {i}
i += 1
~
| Loop not ran.

16
test/tests/while loop.ans Normal file
View file

@ -0,0 +1,16 @@
:i = 0
i <= 10 ~?
| {i}
i += 1
| return in loop:
i = 0
i <= 10 ~?
| {i}
i == 5 ~
@()
i += 1