mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 08:39:30 +00:00
Persist LuaFunctions & add tests
This commit is contained in:
parent
a46ac380e8
commit
9a38dfa34f
11 changed files with 108 additions and 19 deletions
7
test/results/serialize function.ans
Normal file
7
test/results/serialize function.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"bar1" {}"" |
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
7
test/results/serialize lua function.ans
Normal file
7
test/results/serialize lua function.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"2" {}"" |
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
11
test/results/serialize.ans
Normal file
11
test/results/serialize.ans
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"" {}"43" {}"" |
|
||||
--- text ---
|
||||
| {}"" {}"[2, \"\", 5]" {}"" |
|
||||
--- text ---
|
||||
| {}"" {}"*{\"f\":\"b\", 1:2, 2:\"\", 3:\"ok\"}" {}"" |
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -88,6 +88,8 @@ local function run(path, interactive)
|
|||
run_loop(parallel_state, write_output, interactive)
|
||||
write_output("--# main script #--")
|
||||
end)
|
||||
state:define("serialize", "(value)", function(state, value) return ast.String:new(value:serialize(state)) end, true)
|
||||
state:define("deserialize", "(str::string)", function(state, str) return ast.abstract.Node:deserialize(state, str.string) end, true)
|
||||
|
||||
local run_state = state:branch()
|
||||
|
||||
|
|
|
|||
10
test/tests/serialize function.ans
Normal file
10
test/tests/serialize function.ans
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
:f = ()
|
||||
_
|
||||
:$_+_(a::string, b)
|
||||
"{a}{b}"
|
||||
|
||||
:a=1
|
||||
f = $(x)
|
||||
x+a
|
||||
|
||||
|{(f!serialize!deserialize)("bar")}
|
||||
7
test/tests/serialize lua function.ans
Normal file
7
test/tests/serialize lua function.ans
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
:f = ()
|
||||
_
|
||||
:a=1
|
||||
f = $()
|
||||
1+a
|
||||
|
||||
|{(f!serialize!deserialize)!}
|
||||
13
test/tests/serialize.ans
Normal file
13
test/tests/serialize.ans
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
:x = 43
|
||||
|
||||
|{x!serialize!deserialize}
|
||||
|
||||
:l = [2, "", 5]
|
||||
|
||||
|{l!serialize!deserialize}
|
||||
|
||||
:t = *{2, "", 5}
|
||||
t(3) = "ok"
|
||||
t("f") = "b"
|
||||
|
||||
|{t!serialize!deserialize}
|
||||
Loading…
Add table
Add a link
Reference in a new issue