From 82ce53be83a96d6d695eca273a97572cf09bb025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Reuh=20Fildadut?= Date: Thu, 28 Dec 2023 16:51:18 +0100 Subject: [PATCH] First test batch and associated fixes The test runner is also nicer to use. --- ast/Environment.lua | 8 +- ast/List.lua | 4 +- ast/Struct.lua | 3 +- ast/Tuple.lua | 2 +- run tests.sh | 21 +++ stdlib/conditionals.lua | 6 +- stdlib/tag.lua | 4 +- test/results/binary operator overload.ans | 11 ++ test/results/binop assignement.ans | 9 + test/results/choice block.ans | 15 ++ test/results/choice function.ans | 12 ++ ...e line interpolation with choice event.ans | 11 ++ ...ce line interpolation with event flush.ans | 12 ++ ...ice line interpolation with text event.ans | 19 ++ test/results/choice preserve tags.ans | 18 ++ test/results/choice simple.ans | 10 + test/results/closure.ans | 11 ++ test/results/comment.ans | 5 + test/results/condition decorator.ans | 8 + test/results/condition else false.ans | 7 + test/results/condition else true.ans | 7 + test/results/condition elseif false.ans | 7 + test/results/condition elseif true.ans | 7 + test/results/condition false.ans | 5 + test/results/condition operator.ans | 9 + test/results/condition true.ans | 7 + test/results/constant variable.ans | 7 + test/results/custom text formatting.ans | 8 + test/results/define override function.ans | 4 + test/results/define override variable.ans | 5 + test/results/define override.ans | 4 + test/results/define.ans | 5 + test/results/flush.ans | 13 ++ test/results/function arg.ans | 7 + .../function args arity check fail.ans | 7 + test/results/function args.ans | 7 + test/results/function assignement.ans | 15 ++ test/results/function definition.ans | 15 ++ test/results/function name dispatch.ans | 9 + test/results/function no conflict.ans | 5 + .../results/function return exit function.ans | 7 + test/results/function return.ans | 7 + test/results/function scope wrong.ans | 9 + test/results/function scope.ans | 7 + test/results/function selection.ans | 9 + .../function type dispatch ambigous.ans | 9 + test/results/function type dispatch.ans | 9 + test/results/function ufcs arg.ans | 9 + test/results/function ufcs args.ans | 7 + test/results/function.ans | 9 + test/results/implicit multiplication.ans | 15 ++ test/results/lazy boolean operators.ans | 33 ++++ test/results/list assignement.ans | 17 ++ test/results/list index.ans | 17 ++ test/results/loop decorator.ans | 28 +++ test/results/map assignement.ans | 23 +++ test/results/map index.ans | 11 ++ test/results/named arguments.ans | 7 + ...amespace operator arbitrary expression.ans | 7 + test/results/nested conditions.ans | 10 + test/results/nested flush.ans | 20 ++ test/results/optional arguments.ans | 7 + test/results/pair operator.ans | 9 + test/results/return in choice.ans | 10 + test/results/string escaping.ans | 14 ++ test/results/tag decorator nested.ans | 8 + test/results/tag decorator.ans | 8 + test/results/tag empty.ans | 8 + test/results/tag.ans | 8 + test/results/text block.ans | 11 ++ test/results/text break.ans | 9 + test/results/text escaping.ans | 16 ++ test/results/text format.ans | 7 + ...t line interpolation with choice event.ans | 19 ++ ...xt line interpolation with event flush.ans | 13 ++ ...ext line interpolation with text event.ans | 10 + test/results/text.ans | 7 + test/results/unary operator overload.ans | 11 ++ test/results/while loop else.ans | 19 ++ test/results/while loop.ans | 41 +++++ test/run.lua | 174 +++++++++++------- test/tests/binary operator overload.ans | 11 ++ test/tests/binop assignement.ans | 7 + test/tests/choice block.ans | 11 ++ test/tests/choice function.ans | 11 ++ ...e line interpolation with choice event.ans | 11 ++ ...ce line interpolation with event flush.ans | 11 ++ ...ice line interpolation with text event.ans | 17 ++ test/tests/choice preserve tags.ans | 16 ++ test/tests/choice simple.ans | 5 + test/tests/closure.ans | 12 ++ test/tests/comment.ans | 9 + test/tests/condition decorator.ans | 3 + test/tests/condition else false.ans | 6 + test/tests/condition else true.ans | 6 + test/tests/condition elseif false.ans | 8 + test/tests/condition elseif true.ans | 8 + test/tests/condition false.ans | 4 + test/tests/condition operator.ans | 6 + test/tests/condition true.ans | 4 + test/tests/constant variable.ans | 7 + test/tests/custom text formatting.ans | 12 ++ test/tests/define override function.ans | 4 + test/tests/define override variable.ans | 4 + test/tests/define override.ans | 5 + test/tests/define.ans | 1 + test/tests/flush.ans | 7 + test/tests/function arg.ans | 4 + test/tests/function args arity check fail.ans | 4 + test/tests/function args.ans | 4 + test/tests/function assignement.ans | 22 +++ test/tests/function definition.ans | 21 +++ test/tests/function name dispatch.ans | 9 + test/tests/function no conflict.ans | 8 + test/tests/function return exit function.ans | 6 + test/tests/function return.ans | 4 + test/tests/function scope wrong.ans | 4 + test/tests/function scope.ans | 4 + test/tests/function selection.ans | 12 ++ .../tests/function type dispatch ambigous.ans | 7 + test/tests/function type dispatch.ans | 9 + test/tests/function ufcs arg.ans | 6 + test/tests/function ufcs args.ans | 4 + test/tests/function.ans | 9 + test/tests/implicit multiplication.ans | 12 ++ test/tests/lazy boolean operators.ans | 23 +++ test/tests/list assignement.ans | 21 +++ test/tests/list index.ans | 11 ++ test/tests/loop decorator.ans | 5 + test/tests/map assignement.ans | 20 ++ test/tests/map index.ans | 7 + test/tests/named arguments.ans | 4 + ...amespace operator arbitrary expression.ans | 6 + test/tests/nested conditions.ans | 19 ++ test/tests/nested flush.ans | 18 ++ test/tests/optional arguments.ans | 4 + test/tests/pair operator.ans | 5 + test/tests/return in choice.ans | 10 + test/tests/string escaping.ans | 7 + test/tests/tag decorator nested.ans | 4 + test/tests/tag decorator.ans | 3 + test/tests/tag empty.ans | 4 + test/tests/tag.ans | 4 + test/tests/text block.ans | 5 + test/tests/text break.ans | 3 + test/tests/text escaping.ans | 9 + test/tests/text format.ans | 3 + ...t line interpolation with choice event.ans | 16 ++ ...xt line interpolation with event flush.ans | 13 ++ ...ext line interpolation with text event.ans | 10 + test/tests/text.ans | 1 + test/tests/unary operator overload.ans | 11 ++ test/tests/while loop else.ans | 19 ++ test/tests/while loop.ans | 16 ++ 154 files changed, 1586 insertions(+), 78 deletions(-) create mode 100755 run tests.sh create mode 100644 test/results/binary operator overload.ans create mode 100644 test/results/binop assignement.ans create mode 100644 test/results/choice block.ans create mode 100644 test/results/choice function.ans create mode 100644 test/results/choice line interpolation with choice event.ans create mode 100644 test/results/choice line interpolation with event flush.ans create mode 100644 test/results/choice line interpolation with text event.ans create mode 100644 test/results/choice preserve tags.ans create mode 100644 test/results/choice simple.ans create mode 100644 test/results/closure.ans create mode 100644 test/results/comment.ans create mode 100644 test/results/condition decorator.ans create mode 100644 test/results/condition else false.ans create mode 100644 test/results/condition else true.ans create mode 100644 test/results/condition elseif false.ans create mode 100644 test/results/condition elseif true.ans create mode 100644 test/results/condition false.ans create mode 100644 test/results/condition operator.ans create mode 100644 test/results/condition true.ans create mode 100644 test/results/constant variable.ans create mode 100644 test/results/custom text formatting.ans create mode 100644 test/results/define override function.ans create mode 100644 test/results/define override variable.ans create mode 100644 test/results/define override.ans create mode 100644 test/results/define.ans create mode 100644 test/results/flush.ans create mode 100644 test/results/function arg.ans create mode 100644 test/results/function args arity check fail.ans create mode 100644 test/results/function args.ans create mode 100644 test/results/function assignement.ans create mode 100644 test/results/function definition.ans create mode 100644 test/results/function name dispatch.ans create mode 100644 test/results/function no conflict.ans create mode 100644 test/results/function return exit function.ans create mode 100644 test/results/function return.ans create mode 100644 test/results/function scope wrong.ans create mode 100644 test/results/function scope.ans create mode 100644 test/results/function selection.ans create mode 100644 test/results/function type dispatch ambigous.ans create mode 100644 test/results/function type dispatch.ans create mode 100644 test/results/function ufcs arg.ans create mode 100644 test/results/function ufcs args.ans create mode 100644 test/results/function.ans create mode 100644 test/results/implicit multiplication.ans create mode 100644 test/results/lazy boolean operators.ans create mode 100644 test/results/list assignement.ans create mode 100644 test/results/list index.ans create mode 100644 test/results/loop decorator.ans create mode 100644 test/results/map assignement.ans create mode 100644 test/results/map index.ans create mode 100644 test/results/named arguments.ans create mode 100644 test/results/namespace operator arbitrary expression.ans create mode 100644 test/results/nested conditions.ans create mode 100644 test/results/nested flush.ans create mode 100644 test/results/optional arguments.ans create mode 100644 test/results/pair operator.ans create mode 100644 test/results/return in choice.ans create mode 100644 test/results/string escaping.ans create mode 100644 test/results/tag decorator nested.ans create mode 100644 test/results/tag decorator.ans create mode 100644 test/results/tag empty.ans create mode 100644 test/results/tag.ans create mode 100644 test/results/text block.ans create mode 100644 test/results/text break.ans create mode 100644 test/results/text escaping.ans create mode 100644 test/results/text format.ans create mode 100644 test/results/text line interpolation with choice event.ans create mode 100644 test/results/text line interpolation with event flush.ans create mode 100644 test/results/text line interpolation with text event.ans create mode 100644 test/results/text.ans create mode 100644 test/results/unary operator overload.ans create mode 100644 test/results/while loop else.ans create mode 100644 test/results/while loop.ans create mode 100644 test/tests/binary operator overload.ans create mode 100644 test/tests/binop assignement.ans create mode 100644 test/tests/choice block.ans create mode 100644 test/tests/choice function.ans create mode 100644 test/tests/choice line interpolation with choice event.ans create mode 100644 test/tests/choice line interpolation with event flush.ans create mode 100644 test/tests/choice line interpolation with text event.ans create mode 100644 test/tests/choice preserve tags.ans create mode 100644 test/tests/choice simple.ans create mode 100644 test/tests/closure.ans create mode 100644 test/tests/comment.ans create mode 100644 test/tests/condition decorator.ans create mode 100644 test/tests/condition else false.ans create mode 100644 test/tests/condition else true.ans create mode 100644 test/tests/condition elseif false.ans create mode 100644 test/tests/condition elseif true.ans create mode 100644 test/tests/condition false.ans create mode 100644 test/tests/condition operator.ans create mode 100644 test/tests/condition true.ans create mode 100644 test/tests/constant variable.ans create mode 100644 test/tests/custom text formatting.ans create mode 100644 test/tests/define override function.ans create mode 100644 test/tests/define override variable.ans create mode 100644 test/tests/define override.ans create mode 100644 test/tests/define.ans create mode 100644 test/tests/flush.ans create mode 100644 test/tests/function arg.ans create mode 100644 test/tests/function args arity check fail.ans create mode 100644 test/tests/function args.ans create mode 100644 test/tests/function assignement.ans create mode 100644 test/tests/function definition.ans create mode 100644 test/tests/function name dispatch.ans create mode 100644 test/tests/function no conflict.ans create mode 100644 test/tests/function return exit function.ans create mode 100644 test/tests/function return.ans create mode 100644 test/tests/function scope wrong.ans create mode 100644 test/tests/function scope.ans create mode 100644 test/tests/function selection.ans create mode 100644 test/tests/function type dispatch ambigous.ans create mode 100644 test/tests/function type dispatch.ans create mode 100644 test/tests/function ufcs arg.ans create mode 100644 test/tests/function ufcs args.ans create mode 100644 test/tests/function.ans create mode 100644 test/tests/implicit multiplication.ans create mode 100644 test/tests/lazy boolean operators.ans create mode 100644 test/tests/list assignement.ans create mode 100644 test/tests/list index.ans create mode 100644 test/tests/loop decorator.ans create mode 100644 test/tests/map assignement.ans create mode 100644 test/tests/map index.ans create mode 100644 test/tests/named arguments.ans create mode 100644 test/tests/namespace operator arbitrary expression.ans create mode 100644 test/tests/nested conditions.ans create mode 100644 test/tests/nested flush.ans create mode 100644 test/tests/optional arguments.ans create mode 100644 test/tests/pair operator.ans create mode 100644 test/tests/return in choice.ans create mode 100644 test/tests/string escaping.ans create mode 100644 test/tests/tag decorator nested.ans create mode 100644 test/tests/tag decorator.ans create mode 100644 test/tests/tag empty.ans create mode 100644 test/tests/tag.ans create mode 100644 test/tests/text block.ans create mode 100644 test/tests/text break.ans create mode 100644 test/tests/text escaping.ans create mode 100644 test/tests/text format.ans create mode 100644 test/tests/text line interpolation with choice event.ans create mode 100644 test/tests/text line interpolation with event flush.ans create mode 100644 test/tests/text line interpolation with text event.ans create mode 100644 test/tests/text.ans create mode 100644 test/tests/unary operator overload.ans create mode 100644 test/tests/while loop else.ans create mode 100644 test/tests/while loop.ans diff --git a/ast/Environment.lua b/ast/Environment.lua index c44f96d..6697f79 100644 --- a/ast/Environment.lua +++ b/ast/Environment.lua @@ -23,7 +23,9 @@ local VariableMetadata = ast.abstract.Runtime { end end, set = function(self, state, value) - assert(not self.symbol.constant, ("trying to change the value of constant %s"):format(self.symbol.string)) + if self.symbol.constant then + error(("trying to change the value of constant %s"):format(self.symbol.string), 0) + 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 @@ -82,7 +84,7 @@ local Environment = ast.abstract.Runtime { define = function(self, state, symbol, exp) local name = symbol.string if self:defined_in_current(state, symbol) then - error(name.." is already defined in the current scope") + error(name.." is already defined in the current scope", 0) end if (self.partial and not self.partial[name]) or (self.export ~= symbol.exported) then @@ -107,7 +109,7 @@ local Environment = ast.abstract.Runtime { elseif Overloadable:issub(val) then exp = Overload:new(exp, val) elseif self:defined_in_current(state, symbol) then - error(("can't add an overload variant to non-overloadable variable %s defined in the same scope"):format(identifier)) + error(("can't add an overload variant to non-overloadable variable %s defined in the same scope"):format(identifier), 0) end end diff --git a/ast/List.lua b/ast/List.lua index a422cdd..00925a4 100644 --- a/ast/List.lua +++ b/ast/List.lua @@ -49,13 +49,13 @@ List = ast.abstract.Runtime { get = function(self, state, index) local list = self.branched:get(state) if index < 0 then index = #list.list + 1 + index end - if index > #list.list or index == 0 then error("list index out of bounds") end + if index > #list.list or index == 0 then error("list index out of bounds", 0) end return list.list[index] end, set = function(self, state, index, val) local list = self:_prepare_branch(state) if index < 0 then index = #list.list + 1 + index end - if index > #list.list or index == 0 then error("list index out of bounds") end + if index > #list.list+1 or index == 0 then error("list index out of bounds", 0) end list.list[index] = val end, insert = function(self, state, val) diff --git a/ast/Struct.lua b/ast/Struct.lua index b9bf1bb..2bbbbe5 100644 --- a/ast/Struct.lua +++ b/ast/Struct.lua @@ -23,7 +23,8 @@ local TupleToStruct = ast.abstract.Node { _eval = function(self, state) local t = Struct:new() - for i, e in ipairs(self.tuple.list) do + local tuple = self.tuple:eval(state) + for i, e in ipairs(tuple.list) do if Pair:is(e) then t:set(e.name, e.value) else diff --git a/ast/Tuple.lua b/ast/Tuple.lua index da43753..1afc80d 100644 --- a/ast/Tuple.lua +++ b/ast/Tuple.lua @@ -58,7 +58,7 @@ Tuple = ast.abstract.Node { get = function(self, index) if index < 0 then index = #self.list + 1 + index end - if index > #self.list or index == 0 then error("tuple index out of bounds") end + if index > #self.list or index == 0 then error("tuple index out of bounds", 0) end return self.list[index] end } diff --git a/run tests.sh b/run tests.sh new file mode 100755 index 0000000..9a3234c --- /dev/null +++ b/run tests.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +# Run the test suite accross supported Lua versions. +# Note that the test suite require luafilesystem: `luarocks --lua-version=5.4 install luafilesystem` + +echo "/----------------------------\\" +echo "| Running tests with Lua 5.4 |" +echo "\\----------------------------/" +lua5.4 test/run.lua +echo "" + +echo "/----------------------------\\" +echo "| Running tests with Lua 5.3 |" +echo "\\----------------------------/" +lua5.3 test/run.lua +echo "" + +echo "/---------------------------\\" +echo "| Running tests with LuaJIT |" +echo "\\---------------------------/" +luajit test/run.lua diff --git a/stdlib/conditionals.lua b/stdlib/conditionals.lua index c5e731b..6600210 100644 --- a/stdlib/conditionals.lua +++ b/stdlib/conditionals.lua @@ -21,9 +21,8 @@ return { "_~_", "(condition, expression)", function(state, condition, expression) ensure_if_variable(state) if condition:truthy() then - local r = expression:call(state, ArgumentTuple:new()) set_if_variable(state, true) - return r + return expression:call(state, ArgumentTuple:new()) else set_if_variable(state, false) return Nil:new() @@ -37,9 +36,8 @@ return { if last_if_success(state) then return Nil:new() else - local r = expression:call(state, ArgumentTuple:new()) set_if_variable(state, true) - return r + return expression:call(state, ArgumentTuple:new()) end end }, diff --git a/stdlib/tag.lua b/stdlib/tag.lua index ee2da7f..ae400cb 100644 --- a/stdlib/tag.lua +++ b/stdlib/tag.lua @@ -1,5 +1,5 @@ local ast = require("ast") -local Tuple, Table, Struct, ArgumentTuple = ast.Tuple, ast.Table, ast.Struct, ast.ArgumentTuple +local Tuple, Table, Struct, ArgumentTuple, Nil = ast.Tuple, ast.Table, ast.Struct, ast.ArgumentTuple, ast.Nil local tag_manager = require("state.tag_manager") @@ -14,6 +14,8 @@ return { tags_struct = tags elseif Table:is(tags) then tags_struct = tags:to_struct(state) + elseif Nil:is(tags) then + tags_struct = Struct:new() else tags_struct = Struct:from_tuple(Tuple:new(tags)):eval(state) end diff --git a/test/results/binary operator overload.ans b/test/results/binary operator overload.ans new file mode 100644 index 0000000..6c06cf2 --- /dev/null +++ b/test/results/binary operator overload.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {}"" {}"-3" {}""| +--- text --- +| {}"" {}"heh minus lol" {}""| +--- text --- +| {}"" {}"generic minus" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/binop assignement.ans b/test/results/binop assignement.ans new file mode 100644 index 0000000..bb7482f --- /dev/null +++ b/test/results/binop assignement.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"" {}"1" {}""| +--- text --- +| {}"" {}"3" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice block.ans b/test/results/choice block.ans new file mode 100644 index 0000000..9bdfa28 --- /dev/null +++ b/test/results/choice block.ans @@ -0,0 +1,15 @@ +--# run #-- +--- choice --- + > | {}"ye "| +=> | {}"ne "| +--- text --- +| {}"ok"| +--- choice --- +=> | {}"ho "| + > | {}"oh "| +--- text --- +| {}"plop"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice function.ans b/test/results/choice function.ans new file mode 100644 index 0000000..8b60769 --- /dev/null +++ b/test/results/choice function.ans @@ -0,0 +1,12 @@ +--# run #-- +--- choice --- + > | {}"ho "| + > | {}"neol "| +=> | {}"oh "| + > | {}"neol "| +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice line interpolation with choice event.ans b/test/results/choice line interpolation with choice event.ans new file mode 100644 index 0000000..73e445c --- /dev/null +++ b/test/results/choice line interpolation with choice event.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {1:1}"A"| +--- choice --- +=> | {}"Suprise choice! "| + > | {}"Press " {}"JOIN" {}" to jump. "| + > | {}"No "| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice line interpolation with event flush.ans b/test/results/choice line interpolation with event flush.ans new file mode 100644 index 0000000..4a531ec --- /dev/null +++ b/test/results/choice line interpolation with event flush.ans @@ -0,0 +1,12 @@ +--# run #-- +--- text --- +| {1:1}"a"| +--- choice --- +=> | {}"Press " {}"SPLIT" {}" to jump. "| + > | {}"No "| +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice line interpolation with text event.ans b/test/results/choice line interpolation with text event.ans new file mode 100644 index 0000000..8cdfe06 --- /dev/null +++ b/test/results/choice line interpolation with text event.ans @@ -0,0 +1,19 @@ +--# run #-- +--- choice --- +=> | {}"Press " {1:1}"A" {}" to jump. "| + > | {}"No "| +--- text --- +| {}"ok"| +--- choice --- +=> | {}"Other "| +--- text --- +| {}"ok"| +| {1:1}"left"| +--- choice --- +=> | {}"Use " {}" joystick" {}" to move. "| +--- text --- +| {}"ko"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice preserve tags.ans b/test/results/choice preserve tags.ans new file mode 100644 index 0000000..5c6ee43 --- /dev/null +++ b/test/results/choice preserve tags.ans @@ -0,0 +1,18 @@ +--# run #-- +--- choice --- +=> | {1:42}"a "| + > | {}"c "| +--- text --- +| {1:42}"b"| +--- choice --- +=> | {1:42}"a "| + > | {"k":"v"}"d "| +--- text --- +| {1:42}"b"| +| {"k":"v"}"e"| +--- text --- +| {}"f"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/choice simple.ans b/test/results/choice simple.ans new file mode 100644 index 0000000..875c45a --- /dev/null +++ b/test/results/choice simple.ans @@ -0,0 +1,10 @@ +--# run #-- +--- choice --- + > | {}"ye "| +=> | {}"ne "| +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/closure.ans b/test/results/closure.ans new file mode 100644 index 0000000..79c09af --- /dev/null +++ b/test/results/closure.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {}"" {}"5" {}" = 5"| +| {}"" {}"8" {}" = 8"| +--- text --- +| {}"" {}"4" {}" = 4"| +| {}"" {}"7" {}" = 7"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/comment.ans b/test/results/comment.ans new file mode 100644 index 0000000..dfd3304 --- /dev/null +++ b/test/results/comment.ans @@ -0,0 +1,5 @@ +--# run #-- +--- return --- +8 +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition decorator.ans b/test/results/condition decorator.ans new file mode 100644 index 0000000..637dcc7 --- /dev/null +++ b/test/results/condition decorator.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {}"ok"| +| {}"ok bis"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition else false.ans b/test/results/condition else false.ans new file mode 100644 index 0000000..a0b55b3 --- /dev/null +++ b/test/results/condition else false.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition else true.ans b/test/results/condition else true.ans new file mode 100644 index 0000000..a0b55b3 --- /dev/null +++ b/test/results/condition else true.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition elseif false.ans b/test/results/condition elseif false.ans new file mode 100644 index 0000000..a0b55b3 --- /dev/null +++ b/test/results/condition elseif false.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition elseif true.ans b/test/results/condition elseif true.ans new file mode 100644 index 0000000..a0b55b3 --- /dev/null +++ b/test/results/condition elseif true.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition false.ans b/test/results/condition false.ans new file mode 100644 index 0000000..5dc08a6 --- /dev/null +++ b/test/results/condition false.ans @@ -0,0 +1,5 @@ +--# run #-- +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition operator.ans b/test/results/condition operator.ans new file mode 100644 index 0000000..e522787 --- /dev/null +++ b/test/results/condition operator.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"a " {}"b" {}" c"| +--- text --- +| {}"a " {}"()" {}" c"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/condition true.ans b/test/results/condition true.ans new file mode 100644 index 0000000..a0b55b3 --- /dev/null +++ b/test/results/condition true.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"ok"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/constant variable.ans b/test/results/constant variable.ans new file mode 100644 index 0000000..461df20 --- /dev/null +++ b/test/results/constant variable.ans @@ -0,0 +1,7 @@ +--# run #-- +--- error --- +./state/State.lua:145: trying to change the value of constant a + ↳ from test/tests/constant variable.ans:5:3 in assignment: a = 52 + ↳ from ? in block: ::a = 3… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/custom text formatting.ans b/test/results/custom text formatting.ans new file mode 100644 index 0000000..86b806d --- /dev/null +++ b/test/results/custom text formatting.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {}"" {}"\"Name: Darmanin\\\ +Age: 38\"" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/define override function.ans b/test/results/define override function.ans new file mode 100644 index 0000000..cf2c11a --- /dev/null +++ b/test/results/define override function.ans @@ -0,0 +1,4 @@ +--# parse error #-- +a is already defined in the current scope + ↳ from test/tests/define override function.ans:4:4 in definition: :a = 2 + ↳ from ? in block: :a = ($() _)… \ No newline at end of file diff --git a/test/results/define override variable.ans b/test/results/define override variable.ans new file mode 100644 index 0000000..1c922d9 --- /dev/null +++ b/test/results/define override variable.ans @@ -0,0 +1,5 @@ +--# parse error #-- +can't add an overload variant to non-overloadable variable a defined in the same scope + ↳ from test/tests/define override variable.ans:3:1 in definition: :a = ($() _) + ↳ from test/tests/define override variable.ans:3:1 in attach block: :a = ($() _)… + ↳ from ? in block: :a = 2… \ No newline at end of file diff --git a/test/results/define override.ans b/test/results/define override.ans new file mode 100644 index 0000000..07b429f --- /dev/null +++ b/test/results/define override.ans @@ -0,0 +1,4 @@ +--# parse error #-- +a is already defined in the current scope + ↳ from test/tests/define override.ans:3:4 in definition: :a = 2 + ↳ from ? in block: :a = 5… \ No newline at end of file diff --git a/test/results/define.ans b/test/results/define.ans new file mode 100644 index 0000000..5dc08a6 --- /dev/null +++ b/test/results/define.ans @@ -0,0 +1,5 @@ +--# run #-- +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/flush.ans b/test/results/flush.ans new file mode 100644 index 0000000..da34dbe --- /dev/null +++ b/test/results/flush.ans @@ -0,0 +1,13 @@ +--# run #-- +--- text --- +| {}"a"| +--- choice --- +=> | {}"b "| +--- text --- +| {}"c"| +--- choice --- +=> | {}"d "| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function arg.ans b/test/results/function arg.ans new file mode 100644 index 0000000..a375adb --- /dev/null +++ b/test/results/function arg.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"ok" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function args arity check fail.ans b/test/results/function args arity check fail.ans new file mode 100644 index 0000000..b748246 --- /dev/null +++ b/test/results/function args arity check fail.ans @@ -0,0 +1,7 @@ +--# run #-- +--- error --- +./state/State.lua:145: can't call closure ($(a, b) _): expected 2 arguments, received 1 + ↳ from test/tests/function args arity check fail.ans:4:2 in call: f("ok") + ↳ from ? in block: :f = ($(a, b) _)… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function args.ans b/test/results/function args.ans new file mode 100644 index 0000000..694dc13 --- /dev/null +++ b/test/results/function args.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"o" {}"" {}"k" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function assignement.ans b/test/results/function assignement.ans new file mode 100644 index 0000000..0a0b7d4 --- /dev/null +++ b/test/results/function assignement.ans @@ -0,0 +1,15 @@ +--# run #-- +--- text --- +| {}"" {}"5" {}""| +--- text --- +| {}"v=" {}"50" {}""| +--- text --- +| {}"" {}"50" {}""| +--- text --- +| {}"v2=" {}"ok" {}""| +--- text --- +| {}"" {}"3" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function definition.ans b/test/results/function definition.ans new file mode 100644 index 0000000..83a0c6c --- /dev/null +++ b/test/results/function definition.ans @@ -0,0 +1,15 @@ +--# run #-- +--- text --- +| {}"" {}"25" {}" = " {}"25" {}""| +--- text --- +| {}"" {}"4" {}" = " {}"4" {}""| +--- text --- +| {}"" {}"14" {}" == 14"| +--- text --- +| {}"" {}"32" {}" == 32"| +--- text --- +| {}"" {}"49" {}" == 49"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function name dispatch.ans b/test/results/function name dispatch.ans new file mode 100644 index 0000000..7ecb4ec --- /dev/null +++ b/test/results/function name dispatch.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"a"| +--- text --- +| {}"x"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function no conflict.ans b/test/results/function no conflict.ans new file mode 100644 index 0000000..5dc08a6 --- /dev/null +++ b/test/results/function no conflict.ans @@ -0,0 +1,5 @@ +--# run #-- +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function return exit function.ans b/test/results/function return exit function.ans new file mode 100644 index 0000000..4b4989e --- /dev/null +++ b/test/results/function return exit function.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"5" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function return.ans b/test/results/function return.ans new file mode 100644 index 0000000..4b4989e --- /dev/null +++ b/test/results/function return.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"5" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function scope wrong.ans b/test/results/function scope wrong.ans new file mode 100644 index 0000000..96d8388 --- /dev/null +++ b/test/results/function scope wrong.ans @@ -0,0 +1,9 @@ +--# run #-- +--- error --- +./state/State.lua:145: identifier "b" is undefined in branch 0a138a38-3faa-4478-10f6f-1a9de1e0a8e1 + ↳ from test/tests/function scope wrong.ans:4:7 in identifier: b + ↳ from test/tests/function scope wrong.ans:4:1 in text interpolation: | a: {b}| + ↳ from test/tests/function scope wrong.ans:4:1 in translatable: | a: {b}| + ↳ from ? in block: :a = ($() _)… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function scope.ans b/test/results/function scope.ans new file mode 100644 index 0000000..bf77e30 --- /dev/null +++ b/test/results/function scope.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"a: " {}"5" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function selection.ans b/test/results/function selection.ans new file mode 100644 index 0000000..7b82d73 --- /dev/null +++ b/test/results/function selection.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"" {}"plopheh" {}""| +--- text --- +| {}"" {}"4" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function type dispatch ambigous.ans b/test/results/function type dispatch ambigous.ans new file mode 100644 index 0000000..12c9ef2 --- /dev/null +++ b/test/results/function type dispatch ambigous.ans @@ -0,0 +1,9 @@ +--# run #-- +--- error --- +./state/State.lua:145: can't call overload overload<($(a::($(x) )) _), ($(x::($(x) )) _)>: more than one function match (5), matching functions were at least (specificity 1.3): + • (x::($(x) )) + • (a::($(x) )) + ↳ from test/tests/function type dispatch ambigous.ans:7:3 in call: fn(5) + ↳ from ? in block: :fn = ($(x::number) _)… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function type dispatch.ans b/test/results/function type dispatch.ans new file mode 100644 index 0000000..7ecb4ec --- /dev/null +++ b/test/results/function type dispatch.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"a"| +--- text --- +| {}"x"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function ufcs arg.ans b/test/results/function ufcs arg.ans new file mode 100644 index 0000000..8fd7aa1 --- /dev/null +++ b/test/results/function ufcs arg.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"" {}"ok" {}""| +--- text --- +| {}"" {}"ok" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function ufcs args.ans b/test/results/function ufcs args.ans new file mode 100644 index 0000000..694dc13 --- /dev/null +++ b/test/results/function ufcs args.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"o" {}"" {}"k" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/function.ans b/test/results/function.ans new file mode 100644 index 0000000..b634ff6 --- /dev/null +++ b/test/results/function.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"ok"| +--- text --- +| {}"ok2"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/implicit multiplication.ans b/test/results/implicit multiplication.ans new file mode 100644 index 0000000..a184400 --- /dev/null +++ b/test/results/implicit multiplication.ans @@ -0,0 +1,15 @@ +--# run #-- +--- text --- +| {}"" {}"8" {}" = 8"| +--- text --- +| {}"" {}"12" {}" = 12"| +--- text --- +| {}"" {}"6.28" {}" = 2pi"| +--- text --- +| {}"" {}"0.125" {}" = 0.125"| +--- text --- +| {}"" {}"2.1" {}" = 2.1"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/lazy boolean operators.ans b/test/results/lazy boolean operators.ans new file mode 100644 index 0000000..45e3ba9 --- /dev/null +++ b/test/results/lazy boolean operators.ans @@ -0,0 +1,33 @@ +--# run #-- +--- text --- +| {}"a"| +| {}"b"| +| {}"" {}"()" {}" = a b ()"| +--- text --- +| {}"b"| +| {}"" {}"()" {}" = b ()"| +--- text --- +| {}"a"| +| {}"a"| +| {}"" {}"1" {}" = a a 1"| +--- text --- +| {}"b"| +| {}"" {}"()" {}" = b ()"| +--- text --- +| {}"a"| +| {}"" {}"1" {}" = a 1"| +--- text --- +| {}"b"| +| {}"a"| +| {}"" {}"1" {}" = b a 1"| +--- text --- +| {}"a"| +| {}"" {}"1" {}" = a 1"| +--- text --- +| {}"b"| +| {}"b"| +| {}"" {}"()" {}" = b b ()"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/list assignement.ans b/test/results/list assignement.ans new file mode 100644 index 0000000..9dc8ed4 --- /dev/null +++ b/test/results/list assignement.ans @@ -0,0 +1,17 @@ +--# run #-- +--- text --- +| {}"" {}"*[1, 2]" {}""| +--- text --- +| {}"" {}"*[3, 2]" {}""| +--- text --- +| {}"" {}"*[3, 5]" {}""| +--- text --- +| {}"" {}"*[3, 12]" {}""| +--- text --- +| {}"" {}"*[3, 12, 99]" {}""| +--- error --- +./state/State.lua:145: list index out of bounds + ↳ from test/tests/list assignement.ans:21:6 in call: x(5) = 0 + ↳ from ? in block: :x = *[1, 2]… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/list index.ans b/test/results/list index.ans new file mode 100644 index 0000000..e184f32 --- /dev/null +++ b/test/results/list index.ans @@ -0,0 +1,17 @@ +--# run #-- +--- text --- +| {}"" {}"[1, 2, 3]" {}""| +--- text --- +| {}"" {}"1" {}" == " {}"1" {}""| +--- text --- +| {}"" {}"2" {}" == " {}"2" {}""| +--- text --- +| {}"" {}"3" {}" == " {}"3" {}""| +--- error --- +./state/State.lua:145: tuple index out of bounds + ↳ from test/tests/list index.ans:11:4 in call: x(-4) + ↳ from test/tests/list index.ans:11:1 in text interpolation: | {x(-4)}| + ↳ from test/tests/list index.ans:11:1 in translatable: | {x(-4)}| + ↳ from ? in block: :x = [1, 2, 3]… +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/loop decorator.ans b/test/results/loop decorator.ans new file mode 100644 index 0000000..3232840 --- /dev/null +++ b/test/results/loop decorator.ans @@ -0,0 +1,28 @@ +--# run #-- +--- text --- +| {}"" {}"1" {}"" {}"\ +" {}""| +| {}"" {}"2" {}"" {}"\ +" {}""| +| {}"" {}"3" {}"" {}"\ +" {}""| +| {}"" {}"4" {}"" {}"\ +" {}""| +| {}"" {}"5" {}"" {}"\ +" {}""| +| {}"" {}"6" {}"" {}"\ +" {}""| +| {}"" {}"7" {}"" {}"\ +" {}""| +| {}"" {}"8" {}"" {}"\ +" {}""| +| {}"" {}"9" {}"" {}"\ +" {}""| +| {}"" {}"10" {}"" {}"\ +" {}""| +--- text --- +| {}"" {}"11" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/map assignement.ans b/test/results/map assignement.ans new file mode 100644 index 0000000..11360c0 --- /dev/null +++ b/test/results/map assignement.ans @@ -0,0 +1,23 @@ +--# run #-- +--- text --- +| {}"" {}"*{1:1, 2:2}" {}""| +--- text --- +| {}"" {}"()" {}""| +--- text --- +| {}"" {}"*{1:3, 2:2}" {}""| +--- text --- +| {}"" {}"()" {}""| +--- text --- +| {}"" {}"*{\"foo\":\"a\", 1:3, 2:2}" {}""| +--- text --- +| {}"" {}"()" {}""| +--- text --- +| {}"" {}"*{\"bar\":\"b\", \"foo\":\"a\", 1:3, 2:2}" {}""| +--- text --- +| {}"" {}"()" {}""| +--- text --- +| {}"" {}"*{\"bar\":\"b\", \"foo\":\"c\", 1:3, 2:2}" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/map index.ans b/test/results/map index.ans new file mode 100644 index 0000000..9b7f00a --- /dev/null +++ b/test/results/map index.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {}"" {}"{\"ahah\":23, \"k\":23, 3:12}" {}" == " {}"{" {}"3=12, ahah=23, k=23}"| +--- text --- +| {}"" {}"12" {}" == 12"| +--- text --- +| {}"" {}"23" {}" == 23"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/named arguments.ans b/test/results/named arguments.ans new file mode 100644 index 0000000..30b922f --- /dev/null +++ b/test/results/named arguments.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"abc" {}" = " {}"abc" {}" = " {}"abc" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/namespace operator arbitrary expression.ans b/test/results/namespace operator arbitrary expression.ans new file mode 100644 index 0000000..4b4989e --- /dev/null +++ b/test/results/namespace operator arbitrary expression.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"5" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/nested conditions.ans b/test/results/nested conditions.ans new file mode 100644 index 0000000..c63108b --- /dev/null +++ b/test/results/nested conditions.ans @@ -0,0 +1,10 @@ +--# run #-- +--- text --- +| {}"yes"| +--- text --- +| {}"ye"| +| {}"da"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/nested flush.ans b/test/results/nested flush.ans new file mode 100644 index 0000000..485ca0c --- /dev/null +++ b/test/results/nested flush.ans @@ -0,0 +1,20 @@ +--# run #-- +--- text --- +| {}"a"| +--- text --- +| {}"b"| +--- text --- +| {}"c"| +| {}"d"| +--- text --- +| {}"e"| +--- choice --- +=> | {}"f "| +--- text --- +| {}"g"| +--- choice --- +=> | {}"h "| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/optional arguments.ans b/test/results/optional arguments.ans new file mode 100644 index 0000000..30b922f --- /dev/null +++ b/test/results/optional arguments.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"" {}"abc" {}" = " {}"abc" {}" = " {}"abc" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/pair operator.ans b/test/results/pair operator.ans new file mode 100644 index 0000000..b141e43 --- /dev/null +++ b/test/results/pair operator.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"" {}"[\"test\":1, 3:\"p\", \"test\":\"foo\", \"ho\":\"ah\", \"test\":\"test\"]" {}""| +--- text --- +| {}"" {}"[\"name\":1, 3:\"p\", \"test\":\"foo\", \"ho\":\"ah\", \"name\":\"test\"]" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/return in choice.ans b/test/results/return in choice.ans new file mode 100644 index 0000000..58b64b3 --- /dev/null +++ b/test/results/return in choice.ans @@ -0,0 +1,10 @@ +--# run #-- +--- choice --- +=> | {}"a "| +--- text --- +| {}"x"| +| {}"Yes."| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/string escaping.ans b/test/results/string escaping.ans new file mode 100644 index 0000000..f2380d9 --- /dev/null +++ b/test/results/string escaping.ans @@ -0,0 +1,14 @@ +--# run #-- +--- text --- +| {}"expression " {}"a" {}""| +--- text --- +| {}"quote " {}"\"" {}""| +--- text --- +| {}"other codes " {}"\ +" {}" " {}"\\" {}" " {}"\9" {}" " {}"{" {}"braces}"| +--- text --- +| {}"" {}"escaping expressions abc and {stuff} \\ and quotes \"" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/tag decorator nested.ans b/test/results/tag decorator nested.ans new file mode 100644 index 0000000..e8e1222 --- /dev/null +++ b/test/results/tag decorator nested.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {1:1}"foo"| +| {"a":[2, 3], "b":[1, 2], 1:1}"bar"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/tag decorator.ans b/test/results/tag decorator.ans new file mode 100644 index 0000000..cca8490 --- /dev/null +++ b/test/results/tag decorator.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {1:1}"foo"| +| {"a":[2, 3], 1:1}"bar"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/tag empty.ans b/test/results/tag empty.ans new file mode 100644 index 0000000..423d1d6 --- /dev/null +++ b/test/results/tag empty.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {1:1}"foo"| +| {1:1}"bar"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/tag.ans b/test/results/tag.ans new file mode 100644 index 0000000..cca8490 --- /dev/null +++ b/test/results/tag.ans @@ -0,0 +1,8 @@ +--# run #-- +--- text --- +| {1:1}"foo"| +| {"a":[2, 3], 1:1}"bar"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text block.ans b/test/results/text block.ans new file mode 100644 index 0000000..3ae3107 --- /dev/null +++ b/test/results/text block.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {}"a"| +| {}"b c"| +--- text --- +| {}"a"| +| {}"b c"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text break.ans b/test/results/text break.ans new file mode 100644 index 0000000..f691669 --- /dev/null +++ b/test/results/text break.ans @@ -0,0 +1,9 @@ +--# run #-- +--- text --- +| {}"a"| +--- text --- +| {}"b c"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text escaping.ans b/test/results/text escaping.ans new file mode 100644 index 0000000..8f1b040 --- /dev/null +++ b/test/results/text escaping.ans @@ -0,0 +1,16 @@ +--# run #-- +--- text --- +| {}"expression " {}"{" {}"a}"| +--- text --- +| {}"quote " {}"\"" {}""| +--- text --- +| {}"other codes " {}"\ +" {}" " {}"\\" {}" " {}"\9" {}""| +--- text --- +| {}"decorators " {}"#" {}" tag " {}"~" {}" condition " {}"$" {}" fn"| +--- text --- +| {}"sub " {}"[" {}"text]"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text format.ans b/test/results/text format.ans new file mode 100644 index 0000000..bf77e30 --- /dev/null +++ b/test/results/text format.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"a: " {}"5" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text line interpolation with choice event.ans b/test/results/text line interpolation with choice event.ans new file mode 100644 index 0000000..27b79fd --- /dev/null +++ b/test/results/text line interpolation with choice event.ans @@ -0,0 +1,19 @@ +--# run #-- +--- text --- +| {1:1}"A"| +--- choice --- +=> | {}"Surprise choice! "| +--- text --- +| {}"ok"| +| {}"Press " {}"()" {}" to jump."| +--- text --- +| {1:1}"left"| +--- choice --- +=> | {}"Surprise choice! "| +--- text --- +| {}"ok2"| +| {}"Use " {}" joystick" {}" to move."| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text line interpolation with event flush.ans b/test/results/text line interpolation with event flush.ans new file mode 100644 index 0000000..b6f9493 --- /dev/null +++ b/test/results/text line interpolation with event flush.ans @@ -0,0 +1,13 @@ +--# run #-- +--- text --- +| {1:1}"A"| +--- text --- +| {}"Press " {}"()" {}" to jump."| +--- text --- +| {1:1}"left"| +--- text --- +| {}"Use " {}" joystick" {}" to move."| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text line interpolation with text event.ans b/test/results/text line interpolation with text event.ans new file mode 100644 index 0000000..ca8a07b --- /dev/null +++ b/test/results/text line interpolation with text event.ans @@ -0,0 +1,10 @@ +--# run #-- +--- text --- +| {}"Press " {1:1}"A" {}" to jump."| +--- text --- +| {1:2}"left"| +| {}"Use " {}" joystick" {}" to move."| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/text.ans b/test/results/text.ans new file mode 100644 index 0000000..05ec984 --- /dev/null +++ b/test/results/text.ans @@ -0,0 +1,7 @@ +--# run #-- +--- text --- +| {}"a"| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/unary operator overload.ans b/test/results/unary operator overload.ans new file mode 100644 index 0000000..5257364 --- /dev/null +++ b/test/results/unary operator overload.ans @@ -0,0 +1,11 @@ +--# run #-- +--- text --- +| {}"" {}"-5" {}""| +--- text --- +| {}"" {}"minus lol" {}""| +--- text --- +| {}"" {}"generic minus" {}""| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/while loop else.ans b/test/results/while loop else.ans new file mode 100644 index 0000000..f85c5f8 --- /dev/null +++ b/test/results/while loop else.ans @@ -0,0 +1,19 @@ +--# run #-- +--- text --- +| {}"Start with i=" {}"1" {}":"| +--- text --- +| {}"" {}"1" {}""| +--- text --- +| {}"" {}"2" {}""| +--- text --- +| {}"" {}"3" {}""| +--- text --- +| {}"" {}"4" {}""| +--- text --- +| {}"Start with i=" {}"5" {}":"| +--- text --- +| {}"Loop not ran."| +--- return --- +() +--# saved #-- +{} \ No newline at end of file diff --git a/test/results/while loop.ans b/test/results/while loop.ans new file mode 100644 index 0000000..2c5885a --- /dev/null +++ b/test/results/while loop.ans @@ -0,0 +1,41 @@ +--# run #-- +--- text --- +| {}"" {}"0" {}""| +--- text --- +| {}"" {}"1" {}""| +--- text --- +| {}"" {}"2" {}""| +--- text --- +| {}"" {}"3" {}""| +--- text --- +| {}"" {}"4" {}""| +--- text --- +| {}"" {}"5" {}""| +--- text --- +| {}"" {}"6" {}""| +--- text --- +| {}"" {}"7" {}""| +--- text --- +| {}"" {}"8" {}""| +--- text --- +| {}"" {}"9" {}""| +--- text --- +| {}"" {}"10" {}""| +--- text --- +| {}"return in loop:"| +--- text --- +| {}"" {}"0" {}""| +--- text --- +| {}"" {}"1" {}""| +--- text --- +| {}"" {}"2" {}""| +--- text --- +| {}"" {}"3" {}""| +--- text --- +| {}"" {}"4" {}""| +--- text --- +| {}"" {}"5" {}""| +--- return --- +@() +--# saved #-- +{} \ No newline at end of file diff --git a/test/run.lua b/test/run.lua index 976d21c..ba7437b 100644 --- a/test/run.lua +++ b/test/run.lua @@ -1,8 +1,27 @@ +-- Require LuaFileSystem: luarocks install luafilesystem + local lfs = require("lfs") local anselme = require("anselme") local persistent_manager = require("state.persistent_manager") +-- simple random to get the same result across lua versions +local prev = 0 +local function badrandom(a, b) + prev = (4241 * prev + 11) % 6997 + return a + prev % (b-a+1) +end +function math.random(a, b) + if not a and not b then + return badrandom(0, 999) / 1000 + elseif not b then + return badrandom(1, a) + else + return badrandom(a, b) + end +end + +-- run a test file and return the result local function run(path) local state = anselme:new() state:load_stdlib() @@ -10,9 +29,13 @@ local function run(path) local run_state = state:branch() local f = assert(io.open(path, "r")) - local block = anselme.parse(f:read("*a"), path) + local s, block = pcall(anselme.parse, f:read("*a"), path) f:close() + if not s then + return "--# parse error #--\n"..tostring(block) + end + run_state:run(block) local out = { "--# run #--" } @@ -48,6 +71,29 @@ local function run(path) return table.concat(out, "\n") end +-- display an animated loading indicator +io.stdout:setvbuf("no") +local loading = { + loop = { "⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷" }, + loop_pos = 1, + erase_code = "", + + write = function(self, message) + self:clear() + local str = self.loop[self.loop_pos].." "..message + self.erase_code = ("\b"):rep(#str) + io.write(str) + end, + clear = function(self) + io.write(self.erase_code) + end, + update = function(self) + self.loop_pos = self.loop_pos + 1 + if self.loop_pos > #self.loop then self.loop_pos = 1 end + end +} + +-- list tests local tests = {} for test in lfs.dir("test/tests/") do if test:match("%.ans$") then @@ -55,89 +101,85 @@ for test in lfs.dir("test/tests/") do end end -if arg[1] == "help" then - print("usage:") - print("lua test/run.lua: run all the tests") - print("lua test/run.lua write: write missing result files") - print("lua test/run.lua help: display this message") -elseif arg[1] == "write" then - for _, test in ipairs(tests) do - local f = io.open(test:gsub("^test/tests/", "test/results/"), "r") - if f then - f:close() - else - repeat - local rerun = false +-- run! +if not arg[1] or arg[1] == "update" then + local total, failure, errored, notfound = #tests, 0, 0, 0 + + for i, test in ipairs(tests) do + repeat + local rerun = false + + -- load result + local f = io.open(test:gsub("^test/tests/", "test/results/"), "r") + local expected + if f then + expected = f:read("*a") + f:close() + end + + -- run test + local result = run(test) + if result ~= expected then + loading:clear() print("* "..test) - local c = assert(io.open(test, "r")) - local code = c:read("*a") - c:close() - print(" Code:") - print(" "..code:gsub("\n", "\n ")) - local s, result = pcall(run, test) - if not s then - print(" Unexpected error: "..tostring(result)) - local r - repeat - io.write("Edit this file? (y/N) ") - r = io.read("*l"):lower() - until r == "y" or r == "n" or r == "" - if r == "y" then - os.execute(("micro %q"):format(test)) -- hardcoded but oh well - rerun = true - end + if expected then failure = failure + 1 + else notfound = notfound + 1 + end + if arg[1] == "update" then + local c = assert(io.open(test, "r")) + local code = c:read("*a") + c:close() + print(" Code:") + print(" "..code:gsub("\n", "\n ")) + end + if expected then + print(" Expected result: \n "..expected:gsub("\n", "\n ")) + print(" But received: \n "..result:gsub("\n", "\n ")) else - print(" Result:") - print(" "..result:gsub("\n", "\n ")) + print(" No result file found, generated result: \n "..result:gsub("\n", "\n ")) + end + if arg[1] == "update" then local r repeat - io.write("Write this result? (y/N/e) ") + if expected then + io.write("Update this result? (y/N/e) ") + else + io.write("Write this result? (y/N/e) ") + end r = io.read("*l"):lower() until r == "y" or r == "n" or r == "e" or r == "" if r == "y" then local o = assert(io.open(test:gsub("^test/tests/", "test/results/"), "w")) o:write(result) o:close() + if expected then failure = failure - 1 + else notfound = notfound - 1 + end elseif r == "e" then os.execute(("micro %q"):format(test)) -- hardcoded but oh well rerun = true + if expected then failure = failure - 1 + else notfound = notfound - 1 + end end end - until not rerun - end - end -elseif not arg[1] then - local total, failure, errored, notfound = #tests, 0, 0, 0 - - for _, test in ipairs(tests) do - local f = io.open(test:gsub("^test/tests/", "test/results/"), "r") - if f then - local s, result = pcall(run, test) - if not s then - errored = errored + 1 - print("* "..test) - print(" Unexpected error: "..tostring(result)) - else - local expected = f:read("*a") - if result ~= expected then - failure = failure + 1 - print("* "..test) - print(" Expected: \n "..expected:gsub("\n", "\n ")) - print(" But received: \n "..result:gsub("\n", "\n ")) - print("") - end + print("") end - f:close() - else - notfound = notfound + 1 - print("* "..test) - print(" Result file not found.") - print("") - end + until not rerun + + -- status + loading:write(("%s/%s tests ran"):format(i, #tests)) + if i % 10 == 0 then loading:update() end end + loading:clear() print("#### Results ####") - print(("%s successes, %s failures, %s errors, %s missing result files, out of %s tests"):format(total-failure-notfound-errored, failure, errored, notfound, total)) + local successes = total-failure-notfound-errored + print(("%s successes, %s failures, %s errors, %s missing result files, out of %s tests"):format(successes, failure, errored, notfound, total)) + if successes < total then os.exit(1) end else - print("unknown command, run `lua test/run.lua help` for usage") + print("usage:") + print("lua test/run.lua: run all the tests") + print("lua test/run.lua update: run all tests, optionally updating incorrect or missing results") + print("lua test/run.lua help: display this message") end diff --git a/test/tests/binary operator overload.ans b/test/tests/binary operator overload.ans new file mode 100644 index 0000000..fccf2b3 --- /dev/null +++ b/test/tests/binary operator overload.ans @@ -0,0 +1,11 @@ +:$ a - b + @"generic minus" + +:$ a::string - b::string + @a + " minus " + b + +| {2-5} + +| {"heh"-"lol"} + +| {[]-[]} diff --git a/test/tests/binop assignement.ans b/test/tests/binop assignement.ans new file mode 100644 index 0000000..ba5ea22 --- /dev/null +++ b/test/tests/binop assignement.ans @@ -0,0 +1,7 @@ +:c = 1 + +|{c} + +c += 2 + +|{c} \ No newline at end of file diff --git a/test/tests/choice block.ans b/test/tests/choice block.ans new file mode 100644 index 0000000..8a5f0e9 --- /dev/null +++ b/test/tests/choice block.ans @@ -0,0 +1,11 @@ +:@choice = 2 +| ye |> + | no +| ne |> + | ok + +choice = 1 +| ho |> + | plop +| oh |> + | plup diff --git a/test/tests/choice function.ans b/test/tests/choice function.ans new file mode 100644 index 0000000..1d2e4fb --- /dev/null +++ b/test/tests/choice function.ans @@ -0,0 +1,11 @@ +:$ f + | neol |> + | nah + +| ho |> + |plop +f! +| oh |> + |ok +f! +:@choice=3 \ No newline at end of file diff --git a/test/tests/choice line interpolation with choice event.ans b/test/tests/choice line interpolation with choice event.ans new file mode 100644 index 0000000..42066e6 --- /dev/null +++ b/test/tests/choice line interpolation with choice event.ans @@ -0,0 +1,11 @@ +:@choice=1 + +:$ jump button + 1 # |A + | Suprise choice! |> () + @"JOIN" + +| Press {jump button!} to jump. |> + |ok +| No |> + |ko diff --git a/test/tests/choice line interpolation with event flush.ans b/test/tests/choice line interpolation with event flush.ans new file mode 100644 index 0000000..0a04f2b --- /dev/null +++ b/test/tests/choice line interpolation with event flush.ans @@ -0,0 +1,11 @@ +:@choice=1 + +:$ jump button + 1 # | a + + @"SPLIT" + +| Press {jump button!} to jump. |> + | ok +| No |> + | ko diff --git a/test/tests/choice line interpolation with text event.ans b/test/tests/choice line interpolation with text event.ans new file mode 100644 index 0000000..6db0452 --- /dev/null +++ b/test/tests/choice line interpolation with text event.ans @@ -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 diff --git a/test/tests/choice preserve tags.ans b/test/tests/choice preserve tags.ans new file mode 100644 index 0000000..0e97ace --- /dev/null +++ b/test/tests/choice preserve tags.ans @@ -0,0 +1,16 @@ +:choice = 1 + +:$ f + 42 # + | a |> + | b + +f! +| c |> () + +"k":"v" # + f! + | d |> () + | e + +| f diff --git a/test/tests/choice simple.ans b/test/tests/choice simple.ans new file mode 100644 index 0000000..a8790b9 --- /dev/null +++ b/test/tests/choice simple.ans @@ -0,0 +1,5 @@ +| ye |> + | no +| ne |> + | ok +:@choice = 2 diff --git a/test/tests/closure.ans b/test/tests/closure.ans new file mode 100644 index 0000000..b0a0c95 --- /dev/null +++ b/test/tests/closure.ans @@ -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 diff --git a/test/tests/comment.ans b/test/tests/comment.ans new file mode 100644 index 0000000..dd26ad0 --- /dev/null +++ b/test/tests/comment.ans @@ -0,0 +1,9 @@ +((hey couic + 5)) + +((nested ((comments)) d)) + +2 ((end of line)) + +((start of line)) 3 + +5 + ((middle)) 3 diff --git a/test/tests/condition decorator.ans b/test/tests/condition decorator.ans new file mode 100644 index 0000000..e41d320 --- /dev/null +++ b/test/tests/condition decorator.ans @@ -0,0 +1,3 @@ +() ~ |ko +1 ~ |ok +1 ~ |ok bis \ No newline at end of file diff --git a/test/tests/condition else false.ans b/test/tests/condition else false.ans new file mode 100644 index 0000000..81acd23 --- /dev/null +++ b/test/tests/condition else false.ans @@ -0,0 +1,6 @@ +:a = 5 + +a == 2 ~ + |ko +~ + |ok diff --git a/test/tests/condition else true.ans b/test/tests/condition else true.ans new file mode 100644 index 0000000..ad257f4 --- /dev/null +++ b/test/tests/condition else true.ans @@ -0,0 +1,6 @@ +:a = 5 + +a == 5 ~ + |ok +~ + |ko diff --git a/test/tests/condition elseif false.ans b/test/tests/condition elseif false.ans new file mode 100644 index 0000000..4096e9a --- /dev/null +++ b/test/tests/condition elseif false.ans @@ -0,0 +1,8 @@ +:a = 5 + +a == 2 ~ + |ko +~ () ~ + |ko +~ + |ok diff --git a/test/tests/condition elseif true.ans b/test/tests/condition elseif true.ans new file mode 100644 index 0000000..f9ef26e --- /dev/null +++ b/test/tests/condition elseif true.ans @@ -0,0 +1,8 @@ +:a = 5 + +a == 2 ~ + |ko +~ 1 ~ + |ok +~ + |ko diff --git a/test/tests/condition false.ans b/test/tests/condition false.ans new file mode 100644 index 0000000..8f06b16 --- /dev/null +++ b/test/tests/condition false.ans @@ -0,0 +1,4 @@ +:a = 5 + +a == 2 ~ + |ko diff --git a/test/tests/condition operator.ans b/test/tests/condition operator.ans new file mode 100644 index 0000000..2a10c02 --- /dev/null +++ b/test/tests/condition operator.ans @@ -0,0 +1,6 @@ +:$ f + @|b + +|a {5 ~ f!} c + +|a {() ~ f!} c diff --git a/test/tests/condition true.ans b/test/tests/condition true.ans new file mode 100644 index 0000000..22b915d --- /dev/null +++ b/test/tests/condition true.ans @@ -0,0 +1,4 @@ +:a = 5 + +a == 5 ~ + |ok diff --git a/test/tests/constant variable.ans b/test/tests/constant variable.ans new file mode 100644 index 0000000..be2f533 --- /dev/null +++ b/test/tests/constant variable.ans @@ -0,0 +1,7 @@ +::a = 3 + +{a} + +a = 52 + +{a} diff --git a/test/tests/custom text formatting.ans b/test/tests/custom text formatting.ans new file mode 100644 index 0000000..628b36e --- /dev/null +++ b/test/tests/custom text formatting.ans @@ -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} diff --git a/test/tests/define override function.ans b/test/tests/define override function.ans new file mode 100644 index 0000000..fd2506c --- /dev/null +++ b/test/tests/define override function.ans @@ -0,0 +1,4 @@ +:$ a + () + +:a = 2 diff --git a/test/tests/define override variable.ans b/test/tests/define override variable.ans new file mode 100644 index 0000000..441f83f --- /dev/null +++ b/test/tests/define override variable.ans @@ -0,0 +1,4 @@ +:a = 2 + +:$ a + () diff --git a/test/tests/define override.ans b/test/tests/define override.ans new file mode 100644 index 0000000..1fdefc8 --- /dev/null +++ b/test/tests/define override.ans @@ -0,0 +1,5 @@ +:a = 5 + +:a = 2 + +a: {a} diff --git a/test/tests/define.ans b/test/tests/define.ans new file mode 100644 index 0000000..db1999d --- /dev/null +++ b/test/tests/define.ans @@ -0,0 +1 @@ +:a = 5 diff --git a/test/tests/flush.ans b/test/tests/flush.ans new file mode 100644 index 0000000..cc8d131 --- /dev/null +++ b/test/tests/flush.ans @@ -0,0 +1,7 @@ +:@choice = 1 +| a + +| b |> () + +| c +| d |> () diff --git a/test/tests/function arg.ans b/test/tests/function arg.ans new file mode 100644 index 0000000..cbae298 --- /dev/null +++ b/test/tests/function arg.ans @@ -0,0 +1,4 @@ +:$ f(a) + |{a} + +f("ok") diff --git a/test/tests/function args arity check fail.ans b/test/tests/function args arity check fail.ans new file mode 100644 index 0000000..029faac --- /dev/null +++ b/test/tests/function args arity check fail.ans @@ -0,0 +1,4 @@ +:$ f(a, b) + | {a}{b} + +f("ok") diff --git a/test/tests/function args.ans b/test/tests/function args.ans new file mode 100644 index 0000000..3e89644 --- /dev/null +++ b/test/tests/function args.ans @@ -0,0 +1,4 @@ +:$ f(a, b) + | {a}{b} + +f("o", "k") diff --git a/test/tests/function assignement.ans b/test/tests/function assignement.ans new file mode 100644 index 0000000..798475e --- /dev/null +++ b/test/tests/function assignement.ans @@ -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)} diff --git a/test/tests/function definition.ans b/test/tests/function definition.ans new file mode 100644 index 0000000..3f361e4 --- /dev/null +++ b/test/tests/function definition.ans @@ -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 diff --git a/test/tests/function name dispatch.ans b/test/tests/function name dispatch.ans new file mode 100644 index 0000000..5fc9d68 --- /dev/null +++ b/test/tests/function name dispatch.ans @@ -0,0 +1,9 @@ +:$ fn(x) + |x + +:$ fn(a) + |a + +fn(a=5) + +fn(x=5) diff --git a/test/tests/function no conflict.ans b/test/tests/function no conflict.ans new file mode 100644 index 0000000..5fc9055 --- /dev/null +++ b/test/tests/function no conflict.ans @@ -0,0 +1,8 @@ +:$ f(a, b) + () + +:$ f(x) + () + +:$ f(u, v) + () diff --git a/test/tests/function return exit function.ans b/test/tests/function return exit function.ans new file mode 100644 index 0000000..5e7ad2b --- /dev/null +++ b/test/tests/function return exit function.ans @@ -0,0 +1,6 @@ +:$ hey + @5 + |a + @2 + +|{hey!} \ No newline at end of file diff --git a/test/tests/function return.ans b/test/tests/function return.ans new file mode 100644 index 0000000..712461f --- /dev/null +++ b/test/tests/function return.ans @@ -0,0 +1,4 @@ +:$ hey + @5 + +|{hey!} \ No newline at end of file diff --git a/test/tests/function scope wrong.ans b/test/tests/function scope wrong.ans new file mode 100644 index 0000000..1115532 --- /dev/null +++ b/test/tests/function scope wrong.ans @@ -0,0 +1,4 @@ +:$ a + :b = 5 + +| a: {b} diff --git a/test/tests/function scope.ans b/test/tests/function scope.ans new file mode 100644 index 0000000..bb21a8b --- /dev/null +++ b/test/tests/function scope.ans @@ -0,0 +1,4 @@ +:$ a + :@b = 5 + +|a: {a.b} diff --git a/test/tests/function selection.ans b/test/tests/function selection.ans new file mode 100644 index 0000000..4973f67 --- /dev/null +++ b/test/tests/function selection.ans @@ -0,0 +1,12 @@ +:$ a(x::number) + @x + 2 + +:$ x + :$ a(x::string) + @x + "heh" + + |{a("plop")} + + |{a(2)} + +x! diff --git a/test/tests/function type dispatch ambigous.ans b/test/tests/function type dispatch ambigous.ans new file mode 100644 index 0000000..6c65d14 --- /dev/null +++ b/test/tests/function type dispatch ambigous.ans @@ -0,0 +1,7 @@ +:$ fn(x::number) + |x + +:$ fn(a::number) + |a + +fn(5) diff --git a/test/tests/function type dispatch.ans b/test/tests/function type dispatch.ans new file mode 100644 index 0000000..ead73d8 --- /dev/null +++ b/test/tests/function type dispatch.ans @@ -0,0 +1,9 @@ +:$ fn(x::number) + |x + +:$ fn(a::string) + |a + +fn("s") + +fn(5) diff --git a/test/tests/function ufcs arg.ans b/test/tests/function ufcs arg.ans new file mode 100644 index 0000000..200e926 --- /dev/null +++ b/test/tests/function ufcs arg.ans @@ -0,0 +1,6 @@ +:$ f(a) + |{a} + +"ok"!f + +"ok"!f() diff --git a/test/tests/function ufcs args.ans b/test/tests/function ufcs args.ans new file mode 100644 index 0000000..45b385e --- /dev/null +++ b/test/tests/function ufcs args.ans @@ -0,0 +1,4 @@ +:$ f(a, b) + |{a}{b} + +"o"!f("k") diff --git a/test/tests/function.ans b/test/tests/function.ans new file mode 100644 index 0000000..bc28a8b --- /dev/null +++ b/test/tests/function.ans @@ -0,0 +1,9 @@ +:$ f + |ok + +f! + +:g = $ + |ok2 + +g! diff --git a/test/tests/implicit multiplication.ans b/test/tests/implicit multiplication.ans new file mode 100644 index 0000000..9cea42c --- /dev/null +++ b/test/tests/implicit multiplication.ans @@ -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 diff --git a/test/tests/lazy boolean operators.ans b/test/tests/lazy boolean operators.ans new file mode 100644 index 0000000..631d361 --- /dev/null +++ b/test/tests/lazy boolean operators.ans @@ -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 () diff --git a/test/tests/list assignement.ans b/test/tests/list assignement.ans new file mode 100644 index 0000000..68d9ff4 --- /dev/null +++ b/test/tests/list assignement.ans @@ -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 diff --git a/test/tests/list index.ans b/test/tests/list index.ans new file mode 100644 index 0000000..2e4d0ee --- /dev/null +++ b/test/tests/list index.ans @@ -0,0 +1,11 @@ +:x = [1,2,3] + +|{x} + +|{x(1)} == {x(-3)} + +|{x(2)} == {x(-2)} + +|{x(3)} == {x(-1)} + +|{x(-4)} diff --git a/test/tests/loop decorator.ans b/test/tests/loop decorator.ans new file mode 100644 index 0000000..1b3dcfb --- /dev/null +++ b/test/tests/loop decorator.ans @@ -0,0 +1,5 @@ +:i = 0 + +(i += 1; i <= 10) ~? (| {i}\n)! + +|{i} diff --git a/test/tests/map assignement.ans b/test/tests/map assignement.ans new file mode 100644 index 0000000..d3c7e6f --- /dev/null +++ b/test/tests/map assignement.ans @@ -0,0 +1,20 @@ +:x = *{1,2} + +|{x} + +|{x(1) = 3} + +|{x} + +|{x("foo") = "a"} + +|{x} + +|{x("bar") = "b"} + +|{x} + +|{x("foo") = "c"} + +|{x} + diff --git a/test/tests/map index.ans b/test/tests/map index.ans new file mode 100644 index 0000000..562be32 --- /dev/null +++ b/test/tests/map index.ans @@ -0,0 +1,7 @@ +:t = {"ahah":23,"k":23,12} + +|{t} == \{3=12, ahah=23, k=23} + +|{t(3)} == 12 + +|{t("ahah")} == 23 diff --git a/test/tests/named arguments.ans b/test/tests/named arguments.ans new file mode 100644 index 0000000..c97cd42 --- /dev/null +++ b/test/tests/named arguments.ans @@ -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")} diff --git a/test/tests/namespace operator arbitrary expression.ans b/test/tests/namespace operator arbitrary expression.ans new file mode 100644 index 0000000..9b1a779 --- /dev/null +++ b/test/tests/namespace operator arbitrary expression.ans @@ -0,0 +1,6 @@ +:$ f + :@x = 5 + +:a = f + +|{a.("x")} diff --git a/test/tests/nested conditions.ans b/test/tests/nested conditions.ans new file mode 100644 index 0000000..2174744 --- /dev/null +++ b/test/tests/nested conditions.ans @@ -0,0 +1,19 @@ +1 ~ + |yes + () ~ + |no +~ + |nope + 1 ~ + |niet + () ~ + |still no +~ + |nein + +() ~ + |nah +~ + |ye + ~ + |da diff --git a/test/tests/nested flush.ans b/test/tests/nested flush.ans new file mode 100644 index 0000000..087359d --- /dev/null +++ b/test/tests/nested flush.ans @@ -0,0 +1,18 @@ +1 ~ + |a + +|b + +1 ~ + |c +|d + +1 ~ + |e + +| f |> () +:@choice = 1 + +1 ~ + |g +| h |> () diff --git a/test/tests/optional arguments.ans b/test/tests/optional arguments.ans new file mode 100644 index 0000000..9f78454 --- /dev/null +++ b/test/tests/optional arguments.ans @@ -0,0 +1,4 @@ +:$ f(a, b, c="c") + @a + b + c + +|{f("a", "b")} = {f("a", "b", "c")} = {f(b="b", a="a")} diff --git a/test/tests/pair operator.ans b/test/tests/pair operator.ans new file mode 100644 index 0000000..e100abf --- /dev/null +++ b/test/tests/pair operator.ans @@ -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]} diff --git a/test/tests/return in choice.ans b/test/tests/return in choice.ans new file mode 100644 index 0000000..b2f4828 --- /dev/null +++ b/test/tests/return in choice.ans @@ -0,0 +1,10 @@ +:$ f + | a |> + | x + @1 + | y + @2 + +f! == 2 ~ + :@choice = 1 + | Yes. diff --git a/test/tests/string escaping.ans b/test/tests/string escaping.ans new file mode 100644 index 0000000..b820eff --- /dev/null +++ b/test/tests/string escaping.ans @@ -0,0 +1,7 @@ +|expression {"{"a"}"} + +|quote {"\""} + +|other codes {"\n"} {"\\"} {"\t"} \{braces} + +|{"escaping expressions {"a"+"bc"} and \{stuff} \\ and quotes \""} diff --git a/test/tests/tag decorator nested.ans b/test/tests/tag decorator nested.ans new file mode 100644 index 0000000..6800183 --- /dev/null +++ b/test/tests/tag decorator nested.ans @@ -0,0 +1,4 @@ +1 # + |foo + 1 ~ "b":[1,2] # + 1 ~ "a":[2,3] # | bar diff --git a/test/tests/tag decorator.ans b/test/tests/tag decorator.ans new file mode 100644 index 0000000..1f12920 --- /dev/null +++ b/test/tests/tag decorator.ans @@ -0,0 +1,3 @@ +1 # + | foo + "a":[2,3] # | bar diff --git a/test/tests/tag empty.ans b/test/tests/tag empty.ans new file mode 100644 index 0000000..4f47482 --- /dev/null +++ b/test/tests/tag empty.ans @@ -0,0 +1,4 @@ +1 # + |foo + () # + |bar diff --git a/test/tests/tag.ans b/test/tests/tag.ans new file mode 100644 index 0000000..5ee87c9 --- /dev/null +++ b/test/tests/tag.ans @@ -0,0 +1,4 @@ +1 # + |foo + "a":[2,3] # + |bar \ No newline at end of file diff --git a/test/tests/text block.ans b/test/tests/text block.ans new file mode 100644 index 0000000..6eef609 --- /dev/null +++ b/test/tests/text block.ans @@ -0,0 +1,5 @@ +| a +| b c + +|a +|b c \ No newline at end of file diff --git a/test/tests/text break.ans b/test/tests/text break.ans new file mode 100644 index 0000000..563362f --- /dev/null +++ b/test/tests/text break.ans @@ -0,0 +1,3 @@ +|a + +|b c \ No newline at end of file diff --git a/test/tests/text escaping.ans b/test/tests/text escaping.ans new file mode 100644 index 0000000..08e3040 --- /dev/null +++ b/test/tests/text escaping.ans @@ -0,0 +1,9 @@ +|expression \{a} + +|quote \" + +|other codes \n \\ \t + +|decorators \# tag \~ condition \$ fn + +|sub \[text] diff --git a/test/tests/text format.ans b/test/tests/text format.ans new file mode 100644 index 0000000..c9079b7 --- /dev/null +++ b/test/tests/text format.ans @@ -0,0 +1,3 @@ +:a = 5 + +|a: {a} diff --git a/test/tests/text line interpolation with choice event.ans b/test/tests/text line interpolation with choice event.ans new file mode 100644 index 0000000..24b9642 --- /dev/null +++ b/test/tests/text line interpolation with choice event.ans @@ -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. diff --git a/test/tests/text line interpolation with event flush.ans b/test/tests/text line interpolation with event flush.ans new file mode 100644 index 0000000..62ff092 --- /dev/null +++ b/test/tests/text line interpolation with event flush.ans @@ -0,0 +1,13 @@ +:$ jump button + 1 # | A + + @ + +:$ move axis + 1 # | left + + @" joystick" + +| Press {jump button!} to jump. + +| Use {move axis!} to move. diff --git a/test/tests/text line interpolation with text event.ans b/test/tests/text line interpolation with text event.ans new file mode 100644 index 0000000..47f408c --- /dev/null +++ b/test/tests/text line interpolation with text event.ans @@ -0,0 +1,10 @@ +:$ jump button + @1 # | A + +:$ move axis + 2 # | left + @" joystick" + +| Press {jump button!} to jump. + +| Use {move axis!} to move. diff --git a/test/tests/text.ans b/test/tests/text.ans new file mode 100644 index 0000000..e0474e5 --- /dev/null +++ b/test/tests/text.ans @@ -0,0 +1 @@ +|a \ No newline at end of file diff --git a/test/tests/unary operator overload.ans b/test/tests/unary operator overload.ans new file mode 100644 index 0000000..6a87fcc --- /dev/null +++ b/test/tests/unary operator overload.ans @@ -0,0 +1,11 @@ +:$ -f + @"generic minus" + +:$ -f::string + @"minus "+f + +|{-5} + +|{-"lol"} + +|{-[]} diff --git a/test/tests/while loop else.ans b/test/tests/while loop else.ans new file mode 100644 index 0000000..536d413 --- /dev/null +++ b/test/tests/while loop else.ans @@ -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. \ No newline at end of file diff --git a/test/tests/while loop.ans b/test/tests/while loop.ans new file mode 100644 index 0000000..cf283a6 --- /dev/null +++ b/test/tests/while loop.ans @@ -0,0 +1,16 @@ +:i = 0 +i <= 10 ~? + | {i} + + i += 1 + +| return in loop: + +i = 0 +i <= 10 ~? + | {i} + + i == 5 ~ + @() + + i += 1