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

Third test batch

This commit is contained in:
Étienne Fildadut 2023-12-30 23:39:10 +01:00
parent 3edf65dc2a
commit 0eea4b80a6
7 changed files with 131 additions and 1 deletions

View file

@ -65,7 +65,7 @@ local ScopeStack = class {
end
end
self:define_overloadable(sym, LuaFunction:new(parameters, func):eval(self.state))
elseif Node:is(value) then
elseif Node:issub(value) then
self:define(sym, value)
else
self:define(sym, to_anselme(value))

View file

@ -0,0 +1,13 @@
--# run #--
--- text ---
| {}"" {}"pierre" {}" is french" |
--- text ---
| {}"" {}"idk" {}" is esperanto" |
--- error ---
can't call overload overload<($(name::($(x) type(x) == t)) _), ($(name::($(x) type(x) == t)) _)>: no function match (type("nope", 5)), possible functions were:
• (name::($(x) type(x) == t)): type check failure for parameter name in function (name::($(x) type(x) == t))
• (name::($(x) type(x) == t)): type check failure for parameter name in function (name::($(x) type(x) == t))
↳ from test/tests/function custom type dispatch error.ans:14:2 in call: a(type(5, "nope"))
↳ from ? in block: :french name = "french name"…
--# saved #--
{}

View file

@ -0,0 +1,11 @@
--# run #--
--- text ---
| {}"" {}"bob" {}" is english or generic" |
--- text ---
| {}"" {}"pierre" {}" is french" |
--- text ---
| {}"" {}"idk" {}" is english or generic" |
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,42 @@
--# run #--
--- text ---
| {}"numbers:" |
| {}"" {}"0" {}"" |
| {}"" {}"12" {}"" |
| {}"" {}"0.87" {}"" |
| {}"" {}"39.12" {}"" |
--- text ---
| {}"strings:" |
| {}"" {}"foo" {}"" |
--- text ---
| {}"tuple:" |
| {}"" {}"[4, 8, 9]" {}"" |
--- text ---
| {}"struct:" |
| {}"" {}"{1:9, 2:8, 7:4}" {}"" |
--- text ---
| {}"symbols:" |
| {}"" {}":ab" {}"" |
--- text ---
| {}"anchor:" |
| {}"" {}"#jdfe" {}"" |
| {}"" {}"#foo bar" {}"" |
--- text ---
| {}"boolean:" |
| {}"" {}"false" {}"" |
| {}"" {}"true" {}"" |
--- text ---
| {}"nil:" |
| {}"" {}"()" {}"" |
--- text ---
| {}"pair:" |
| {}"" {}"6:8" {}"" |
| {}"" {}"\"d\":[]" {}"" |
--- text ---
| {}"function:" |
| {}"" {}"($() 12)" {}"" |
| {}"" {}"($(x) x)" {}"" |
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,14 @@
:french name="french name"
:esperanto name="esperanto name"
:$ a(name::is(esperanto name))
|{name!value} is esperanto
:$ a(name::is(french name))
|{name!value} is french
a("pierre"!type(french name))
a("idk"!type(esperanto name))
a(5!type("nope"))

View file

@ -0,0 +1,14 @@
:french name="french name"
:esperanto name="esperanto name"
:$ a(name)
|{name!value} is english or generic
:$ a(name::is(french name))
|{name!value} is french
a("bob")
a("pierre"!type(french name))
a("idk"!type(esperanto name))

36
test/tests/litterals.ans Normal file
View file

@ -0,0 +1,36 @@
| numbers:
| {0}
| {12}
| {.87}
| {39.12}
| strings:
| {"foo"}
| tuple:
| {[4,8,9]}
| struct:
| {{7:4,2:8,1:9}}
| symbols:
| {:ab}
| anchor:
| {#jdfe}
| {#foo bar}
| boolean:
| {false}
| {true}
| nil:
| {()}
| pair:
| {6:8}
| {("d"):([])}
| function:
| {$12}
| {$(x)x}