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
|
|
@ -17,7 +17,9 @@ AttachBlock = ast.abstract.Node {
|
|||
end,
|
||||
|
||||
_format = function(self, state, priority, indentation, ...)
|
||||
return self.expression:format(state, priority, indentation, ...).."\n\t"..self.block:format(state, priority, indentation + 1, ...)
|
||||
local exp = self.expression:format(state, priority, indentation, ...)
|
||||
if exp:sub(-2) == " _" then exp = exp:sub(1, -3) end
|
||||
return exp.."\n\t"..self.block:format(state, priority, indentation + 1, ...)
|
||||
end,
|
||||
|
||||
traverse = function(self, fn, ...)
|
||||
|
|
|
|||
|
|
@ -50,12 +50,9 @@ local Definition = ast.abstract.Node {
|
|||
symbol:prepare(state)
|
||||
val:prepare(state)
|
||||
|
||||
if self.symbol.alias then
|
||||
state.scope:define(symbol:with{ alias = false }, val) -- disable alias to avoid call in Identifier:_prepare
|
||||
elseif Overloadable:issub(val) then
|
||||
state.scope:define_overloadable(symbol, val)
|
||||
else
|
||||
state.scope:define(symbol, val)
|
||||
-- predefine exported variables
|
||||
if symbol.exported then
|
||||
self:eval(state)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ local VariableMetadata = ast.abstract.Runtime {
|
|||
end
|
||||
if self.symbol.type_check then
|
||||
local r = self.symbol.type_check:call(state, ArgumentTuple:new(value))
|
||||
if not r:truthy() then error(("type check failure for %s; %s does not satisfy %s"):format(self.symbol.string, value, self.symbol.type_check)) end
|
||||
if not r:truthy() then error(("type check failure for %s; %s does not satisfy %s"):format(self.symbol.string, value, self.symbol.type_check), 0) end
|
||||
end
|
||||
if self.symbol.alias then
|
||||
local assign_args = ArgumentTuple:new()
|
||||
|
|
@ -185,14 +185,12 @@ local Environment = ast.abstract.Runtime {
|
|||
return self:_get_variable(state, identifier):set(state, val)
|
||||
end,
|
||||
|
||||
-- returns a list {[symbol]=val,...} of all exported variables in the current strict layer
|
||||
-- returns a list {[symbol]=val,...} of all exported variables (evaluated) in the current strict layer
|
||||
list_exported = function(self, state)
|
||||
assert(self.export, "not an export scope layer")
|
||||
local r = {}
|
||||
for _, vm in self.variables:iter(state) do
|
||||
if vm.symbol.exported then
|
||||
r[vm.symbol] = vm:get(state)
|
||||
end
|
||||
r[vm.symbol] = vm:get(state)
|
||||
end
|
||||
return r
|
||||
end,
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ Node = class {
|
|||
local r = {}
|
||||
for _, tr in ipairs(l) do
|
||||
table.insert(r, "(("..tr.source.."))")
|
||||
table.insert(r, Call:new(Identifier:new("_#_"), ArgumentTuple:new(tr.context, Identifier:new("_"))))
|
||||
table.insert(r, Call:new(Identifier:new("_#_"), ArgumentTuple:new(tr.context, Identifier:new("_"))):format())
|
||||
table.insert(r, "\t"..Call:new(Identifier:new("_->_"), ArgumentTuple:new(tr, tr)):format())
|
||||
table.insert(r, "")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,15 @@ local parser = require("parser")
|
|||
local binser = require("lib.binser")
|
||||
local anselme
|
||||
|
||||
-- same as assert, but do not add position information
|
||||
-- useful for errors raised from anselme (don't care about Lua error position)
|
||||
local function assert0(v, message, ...)
|
||||
if not v then
|
||||
error(message, 0)
|
||||
end
|
||||
return v, message, ...
|
||||
end
|
||||
|
||||
local State
|
||||
State = class {
|
||||
type = "anselme state",
|
||||
|
|
@ -142,7 +151,7 @@ State = class {
|
|||
run = function(self, code, source)
|
||||
assert(not self:active(), "a script is already active")
|
||||
self._coroutine = coroutine.create(function()
|
||||
local r = assert(self:eval_local(code, source))
|
||||
local r = assert0(self:eval_local(code, source))
|
||||
event_manager:final_flush(self)
|
||||
return "return", r
|
||||
end)
|
||||
|
|
@ -174,7 +183,7 @@ State = class {
|
|||
assert(self:active(), "trying to interrupt but no script is currently active")
|
||||
if code then
|
||||
self._coroutine = coroutine.create(function()
|
||||
local r = assert(self:eval_local(code, source))
|
||||
local r = assert0(self:eval_local(code, source))
|
||||
event_manager:final_flush(self)
|
||||
self.scope:reset() -- scope stack is probably messed up after the switch
|
||||
return "return", r
|
||||
|
|
|
|||
33
test/results/choice with decorators.ans
Normal file
33
test/results/choice with decorators.ans
Normal 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 #--
|
||||
{}
|
||||
9
test/results/constant variable list.ans
Normal file
9
test/results/constant variable list.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"*[3]" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"*[3, 52]" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
--# run #--
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31mtrying to change the value of constant a[0m
|
||||
[0m[31m[0m[31mtrying to change the value of constant a[0m
|
||||
↳ from [4mtest/tests/constant variable.ans:5:3[0m in assignment: [2ma = 52[0m[0m
|
||||
↳ from [4m?[0m in block: [2m::a = 3…[0m
|
||||
--# saved #--
|
||||
|
|
|
|||
11
test/results/constrained variable assignement.ans
Normal file
11
test/results/constrained variable assignement.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"type(\"kg\", 5)" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"type(\"kg\", 12)" {}""|
|
||||
--- error ---
|
||||
[0m[31m[0m[31mtype check failure for weigh; 32 does not satisfy ($(x) type(x) == t)[0m
|
||||
↳ from [4mtest/tests/constrained variable assignement.ans:9:7[0m in assignment: [2mweigh = 32[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:weigh::is("kg") = type(5, "kg")…[0m
|
||||
--# saved #--
|
||||
{}
|
||||
9
test/results/constrained variable definition.ans
Normal file
9
test/results/constrained variable definition.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"type(\"kg\", 5)" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"12" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
--# parse error #--
|
||||
--# run #--
|
||||
--- error ---
|
||||
[0m[31m[0m[31ma is already defined in the current scope[0m
|
||||
↳ from [4mtest/tests/define override function.ans:4:4[0m in definition: [2m:a = 2[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:a = ($() _)…[0m
|
||||
↳ from [4m?[0m in block: [2m:a = ($() _)…[0m
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
--# parse error #--
|
||||
--# run #--
|
||||
--- error ---
|
||||
[0m[31m[0m[31m[0m[31mcan't add an overload variant to non-overloadable variable a defined in the same scope[0m
|
||||
↳ from [4mtest/tests/define override variable.ans:3:1[0m in definition: [2m:a = ($() _)[0m[0m
|
||||
↳ from [4mtest/tests/define override variable.ans:3:1[0m in attach block: [2m:a = ($() _)…[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:a = 2…[0m
|
||||
↳ from [4m?[0m in block: [2m:a = 2…[0m
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
--# parse error #--
|
||||
--# run #--
|
||||
--- error ---
|
||||
[0m[31m[0m[31ma is already defined in the current scope[0m
|
||||
↳ from [4mtest/tests/define override.ans:3:4[0m in definition: [2m:a = 2[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:a = 5…[0m
|
||||
↳ from [4m?[0m in block: [2m:a = 5…[0m
|
||||
--# saved #--
|
||||
{}
|
||||
27
test/results/equality operator.ans
Normal file
27
test/results/equality operator.ans
Normal 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 #--
|
||||
{}
|
||||
5
test/results/exported variable.ans
Normal file
5
test/results/exported variable.ans
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
--# run #--
|
||||
--- return ---
|
||||
"ok"
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
--# run #--
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31mcan't call closure ($(a, b) _): expected 2 arguments, received 1[0m
|
||||
[0m[31m[0m[31mcan't call closure ($(a, b) _): expected 2 arguments, received 1[0m
|
||||
↳ from [4mtest/tests/function args arity check fail.ans:4:2[0m in call: [2mf("ok")[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:f = ($(a, b) _)…[0m
|
||||
--# saved #--
|
||||
|
|
|
|||
21
test/results/function exported.ans
Normal file
21
test/results/function exported.ans
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"local:"|
|
||||
--- text ---
|
||||
| {}"" {}"1" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"1" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"1" {}""|
|
||||
--- text ---
|
||||
| {}"exported:"|
|
||||
--- text ---
|
||||
| {}"" {}"1" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"2" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"3" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
8
test/results/function return exit function nested.ans
Normal file
8
test/results/function return exit function nested.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"5" {}""|
|
||||
| {}"" {}"2" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
8
test/results/function return nested.ans
Normal file
8
test/results/function return nested.ans
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"5" {}""|
|
||||
| {}"" {}"2" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
--# run #--
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31m[0m[31m[0m[31midentifier "b" is undefined in branch 0a138a38-3faa-4478-10f6f-1a9de1e0a8e1[0m
|
||||
[0m[31m[0m[31m[0m[31m[0m[31midentifier "b" is undefined in branch 0a138a38-3faa-4478-10f6f-1a9de1e0a8e1[0m
|
||||
↳ from [4mtest/tests/function scope wrong.ans:4:7[0m in identifier: [2mb[0m[0m
|
||||
↳ from [4mtest/tests/function scope wrong.ans:4:1[0m in text interpolation: [2m| a: {b}|[0m[0m
|
||||
↳ from [4mtest/tests/function scope wrong.ans:4:1[0m in translatable: [2m| a: {b}|[0m[0m
|
||||
|
|
|
|||
65
test/results/function scoped mutable.ans
Normal file
65
test/results/function scoped mutable.ans
Normal 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 #--
|
||||
{}
|
||||
61
test/results/function scoped nested.ans
Normal file
61
test/results/function scoped nested.ans
Normal 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 #--
|
||||
{}
|
||||
33
test/results/function scoped recursive.ans
Normal file
33
test/results/function scoped recursive.ans
Normal 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 #--
|
||||
{}
|
||||
21
test/results/function scoped.ans
Normal file
21
test/results/function scoped.ans
Normal 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 #--
|
||||
{}
|
||||
12
test/results/function separate variable from variants.ans
Normal file
12
test/results/function separate variable from variants.ans
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
--# run #--
|
||||
--- error ---
|
||||
[0m[31m[0m[31m[0m[31m[0m[31mcan'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>))[0m
|
||||
↳ from [4mtest/tests/function separate variable from variants.ans:10:4[0m in call: [2mf . "a"[0m[0m
|
||||
↳ from [4mtest/tests/function separate variable from variants.ans:10:1[0m in text interpolation: [2m| {(f . "a")} = 2|[0m[0m
|
||||
↳ from [4mtest/tests/function separate variable from variants.ans:10:1[0m in translatable: [2m| {(f . "a")} = 2|[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:f = ($() _)…[0m
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
--# run #--
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31mcan'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):
|
||||
[0m[31m[0m[31mcan'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>))[0m
|
||||
↳ from [4mtest/tests/function type dispatch ambigous.ans:7:3[0m in call: [2mfn(5)[0m[0m
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
--- text ---
|
||||
| {}"" {}"*[3, 12, 99]" {}""|
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31mlist index out of bounds[0m
|
||||
[0m[31m[0m[31mlist index out of bounds[0m
|
||||
↳ from [4mtest/tests/list assignement.ans:21:6[0m in call: [2mx(5) = 0[0m[0m
|
||||
↳ from [4m?[0m in block: [2m:x = *[1, 2]…[0m
|
||||
--# saved #--
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
--- text ---
|
||||
| {}"" {}"3" {}" == " {}"3" {}""|
|
||||
--- error ---
|
||||
./state/State.lua:145: [0m[31m[0m[31m[0m[31m[0m[31mtuple index out of bounds[0m
|
||||
[0m[31m[0m[31m[0m[31m[0m[31mtuple index out of bounds[0m
|
||||
↳ from [4mtest/tests/list index.ans:11:4[0m in call: [2mx(-4)[0m[0m
|
||||
↳ from [4mtest/tests/list index.ans:11:1[0m in text interpolation: [2m| {x(-4)}|[0m[0m
|
||||
↳ from [4mtest/tests/list index.ans:11:1[0m in translatable: [2m| {x(-4)}|[0m[0m
|
||||
|
|
|
|||
9
test/results/return children.ans
Normal file
9
test/results/return children.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"50" {}" = 50"|
|
||||
--- text ---
|
||||
| {}"" {}"3" {}" = 3"|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
9
test/results/tag operator.ans
Normal file
9
test/results/tag operator.ans
Normal 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 #--
|
||||
{}
|
||||
7
test/results/text buffer with tags.ans
Normal file
7
test/results/text buffer with tags.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {1:1}"lol"|
|
||||
--- return ---
|
||||
@| {}"a " {1:2}"d" {}" " {1:3}"t" {}" b"|
|
||||
--# saved #--
|
||||
{}
|
||||
7
test/results/text buffer.ans
Normal file
7
test/results/text buffer.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"lol"|
|
||||
--- return ---
|
||||
@| {}"a " {}"d" {}" b"|
|
||||
--# saved #--
|
||||
{}
|
||||
11
test/results/translate context.ans
Normal file
11
test/results/translate context.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"Hello"|
|
||||
--- text ---
|
||||
| {}"Bonjour"|
|
||||
--- text ---
|
||||
| {}"Hello"|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
9
test/results/translate string.ans
Normal file
9
test/results/translate string.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"Hello" {}""|
|
||||
--- text ---
|
||||
| {}"" {}"Bonjour" {}""|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
9
test/results/translate text.ans
Normal file
9
test/results/translate text.ans
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"Hello"|
|
||||
--- text ---
|
||||
| {}"Bonjour"|
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
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