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

Firth test batch and associated fixes

This commit is contained in:
Étienne Fildadut 2023-12-31 14:30:14 +01:00
parent aa8dfbd498
commit 409a2e7095
22 changed files with 516 additions and 5 deletions

View file

@ -1,6 +1,8 @@
local ast = require("anselme.ast") local ast = require("anselme.ast")
local ArgumentTuple, Nil, Boolean, Identifier, Return = ast.ArgumentTuple, ast.Nil, ast.Boolean, ast.Identifier, ast.Return local ArgumentTuple, Nil, Boolean, Identifier, Return = ast.ArgumentTuple, ast.Nil, ast.Boolean, ast.Identifier, ast.Return
local resume_manager = require("anselme.state.resume_manager")
local if_identifier = Identifier:new("_if_status") local if_identifier = Identifier:new("_if_status")
local if_symbol = if_identifier:to_symbol() local if_symbol = if_identifier:to_symbol()
@ -20,7 +22,7 @@ return {
{ {
"_~_", "(condition, expression)", function(state, condition, expression) "_~_", "(condition, expression)", function(state, condition, expression)
ensure_if_variable(state) ensure_if_variable(state)
if condition:truthy() then if condition:truthy() or resume_manager:resuming(state) then--expression:contains_current_resume_target(state) then TODO fix
set_if_variable(state, true) set_if_variable(state, true)
return expression:call(state, ArgumentTuple:new()) return expression:call(state, ArgumentTuple:new())
else else
@ -33,11 +35,11 @@ return {
"~_", "(expression)", "~_", "(expression)",
function(state, expression) function(state, expression)
ensure_if_variable(state) ensure_if_variable(state)
if last_if_success(state) then if not last_if_success(state) or resume_manager:resuming(state) then--expression:contains_current_resume_target(state) then TODO fix
return Nil:new()
else
set_if_variable(state, true) set_if_variable(state, true)
return expression:call(state, ArgumentTuple:new()) return expression:call(state, ArgumentTuple:new())
else
return Nil:new()
end end
end end
}, },

View file

@ -0,0 +1,45 @@
--# run #--
--- text ---
| {}"From start:" |
| {}"x" |
--- text ---
| {}"d" |
--- text ---
| {}"From p checkpoint:" |
| {}"a" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"From q checkpoint:" |
| {}"b" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"From q checkpoint again:" |
| {}"b" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"Go to p again by setting checkpoint manually:" |
| {}"a" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"From q again:" |
| {}"b" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- return ---
()
--# saved #--
{"f.checkpoint":#q, "f.reached":*{#p:1, #q:2}, "f.run":6}

View file

@ -0,0 +1,9 @@
--# run #--
--- text ---
| {}"Seen: " {}"2" {}"" |
--- text ---
| {}"Reached: " {}"1" {}"" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:1, #s:2}, "f.run":2}

View file

@ -1,6 +1,8 @@
--# run #-- --# run #--
--- error --- --- error ---
can'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: can't call overload overload<($(s::($(x) type(x) == t), k::($(x) <lua function>)) = val; _), ($(s::($(x) type(x) == t), k::($(x) <lua function>)) _), ($(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:
• (s::($(x) type(x) == t), k::($(x) <lua function>)) = val: expected 3 arguments, received 2
• (s::($(x) type(x) == t), k::($(x) <lua function>)): type check failure for parameter s in function (s::($(x) type(x) == t), k::($(x) <lua function>))
• (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>)) = 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>)) • (c::($(x) <lua function>), s::($(x) <lua function>)): type check failure for parameter c in function (c::($(x) <lua function>), s::($(x) <lua function>))

View file

@ -0,0 +1,17 @@
--# run #--
--- text ---
| {}"Force run checkpoint:" |
| {}"a" |
| {}"b" |
--- text ---
| {}"From checkpoint:" |
| {}"a" |
| {}"b" |
--- text ---
| {}"Force no checkpoint:" |
| {}"x" |
| {}"b" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:1}, "f.run":3}

View file

@ -0,0 +1,17 @@
--# run #--
--- text ---
| {}"Force run from checkpoint:" |
| {}"a" |
| {}"b" |
--- text ---
| {}"From checkpoint:" |
| {}"a" |
| {}"b" |
--- text ---
| {}"Force no checkpoint:" |
| {}"x" |
| {}"b" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:1}, "f.run":3}

View file

@ -0,0 +1,17 @@
--# run #--
--- text ---
| {}"No checkpoint:" |
| {}"x" |
| {}"b" |
--- text ---
| {}"From checkpoint:" |
| {}"a" |
| {}"b" |
--- text ---
| {}"Force no checkpoint:" |
| {}"x" |
| {}"b" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:2}, "f.run":3}

View file

@ -0,0 +1,7 @@
--# run #--
--- text ---
| {}"b" |
--- return ---
()
--# saved #--
{}

View file

@ -0,0 +1,38 @@
--# run #--
--- text ---
| {}"From start:" |
| {}"x" |
--- text ---
| {}"d" |
--- text ---
| {}"From p checkpoint:" |
| {}"a" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"From q checkpoint:" |
| {}"b" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"From q checkpoint again:" |
| {}"b" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- text ---
| {}"Force p checkpoint:" |
| {}"a" |
--- text ---
| {}"c" |
--- text ---
| {}"d" |
--- return ---
()
--# saved #--
{"f.checkpoint":#q, "f.reached":*{#p:1, #q:2}, "f.run":5}

View file

@ -0,0 +1,21 @@
--# run #--
--- text ---
| {"a":"a"}"a" |
--- text ---
| {"a":"a", "b":"b", "x":"x"}"c" |
--- text ---
| {"a":"a"}"d" |
--- text ---
| {}"e" |
--- text ---
| {"a":"a", "b":"b", "c":"c", "x":"x"}"b" |
--- text ---
| {"a":"a", "b":"b", "x":"x"}"c" |
--- text ---
| {"a":"a"}"d" |
--- text ---
| {}"e" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:1}, "f.run":2}

View file

@ -0,0 +1,85 @@
--# run #--
--- text ---
| {}"f:" |
--- choice ---
> | {}"a" |
=> | {}"b" |
--- text ---
| {}"-> b" |
--- choice ---
=> | {}"c" |
--- text ---
| {}"-> c" |
| {}"f from #p:" |
--- choice ---
> | {}"aa" |
=> | {}"ab" |
--- text ---
| {}"-> ab" |
--- text ---
| {}"g:" |
--- choice ---
> | {}"a" |
=> | {}"b" |
--- text ---
| {}"-> b" |
| {}"autoflush" |
--- choice ---
=> | {}"c" |
--- text ---
| {}"-> c" |
| {}"g from #p:" |
--- choice ---
> | {}"aa" |
=> | {}"ab" |
--- text ---
| {}"-> ab" |
| {}"autoflush" |
--- choice ---
=> | {}"c" |
--- text ---
| {}"-> c" |
--- text ---
| {}"h:" |
--- choice ---
=> | {}"a" |
> | {}"b" |
> | {}"c" |
--- text ---
| {}"-> a" |
--- choice ---
=> | {}"aa" |
> | {}"ab" |
--- text ---
| {}"-> aa" |
| {}"h from #p:" |
--- choice ---
=> | {}"aa" |
> | {}"ab" |
> | {}"c" |
--- text ---
| {}"-> aa" |
--- text ---
| {}"i:" |
--- choice ---
=> | {}"a" |
> | {}"b" |
> | {}"c" |
--- text ---
| {}"-> a" |
--- choice ---
=> | {}"aa" |
> | {}"ab" |
--- text ---
| {}"-> aa" |
| {}"i from #p:" |
--- choice ---
=> | {}"aa" |
> | {}"ab" |
> | {}"c" |
--- text ---
| {}"-> aa" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.run":2, "g.checkpoint":#p, "g.run":2, "h.checkpoint":#p, "h.reached":*{#p:1}, "h.run":2, "i.checkpoint":#p, "i.reached":*{#p:1}, "i.run":2}

View file

@ -0,0 +1,13 @@
--# run #--
--- text ---
| {}"x" |
--- text ---
| {}"x" |
--- text ---
| {}"y" |
--- text ---
| {}"x" |
--- return ---
()
--# saved #--
{"f.checkpoint":#p, "f.reached":*{#p:1}, "f.run":2, "g.checkpoint":#p, "g.run":2}

View file

@ -0,0 +1,30 @@
:f = "f"!script($_)
|x
#p!checkpoint($_)
|a
#q!checkpoint($_)
|b
|c
|d
|From start:
f!
|From p checkpoint:
f!
|From q checkpoint:
f!
|From q checkpoint again:
f!
|Go to p again by setting checkpoint manually:
f.current checkpoint = #p
f!
|From q again:
f!

View file

@ -0,0 +1,11 @@
:f = "f"!script($_)
#p!checkpoint
#s!check
f!
f!
|Seen: {f.reached(#s)}
|Reached: {f.reached(#p)}

View file

@ -0,0 +1,14 @@
:f = "f"!script($_)
|x
#p!checkpoint($_)
|a
|b
|Force run checkpoint:
f!from(#p)
|From checkpoint:
f!
|Force no checkpoint:
f!from()

View file

@ -0,0 +1,14 @@
:f = "f"!script($_)
|x
#p!checkpoint($_)
|a
|b
|Force run from checkpoint:
f!from(#p)
|From checkpoint:
f!
|Force no checkpoint:
f!from()

View file

@ -0,0 +1,14 @@
: f = "f"!script($_)
|x
#p!checkpoint($_)
|a
|b
|No checkpoint:
f!
|From checkpoint:
f!
|Force no checkpoint:
f!from()

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

@ -0,0 +1,4 @@
:f = "g"!script($_)
#p!checkpoint($_)
|a
|b

View file

@ -0,0 +1,26 @@
:f = "f"!script($_)
|x
#p!checkpoint($_)
|a
#q!checkpoint($_)
|b
|c
|d
|From start:
f!
|From p checkpoint:
f!
|From q checkpoint:
f!
|From q checkpoint again:
f!
|Force p checkpoint:
f!from(#p)

View file

@ -0,0 +1,17 @@
:f = "f"!script($_)
"a":"a" #
|a
1 ~ "x":"x" #
"b":"b" #
#p!checkpoint($_)
"c":"c"# |b
|c
|d
|e
f!
f!

View file

@ -0,0 +1,87 @@
:@choice = 2
:f = "f"!script($_)
| a |>
|-> a
#p!checkpoint
| aa |>
|-> aa
| ab |>
|-> ab
| b |>
|-> b
choice = 2
| c |>
|-> c
choice=1
| f:
f!
| f from #p:
f!from(#p)
:g = "g"!script($_)
| a |>
|-> a
#p!checkpoint
| aa |>
|-> aa
| ab |>
|-> ab
| b |>
|-> b
choice = 2
|autoflush
| c |>
|-> c
choice = 1
| g:
g!
| g from #p:
g!from(#p)
:h = "h"!script($_)
1 ~
| a |>
|-> a
#p!checkpoint
| aa |>
|-> aa
| ab |>
|-> ab
choice = 1
| b |>
|-> b
| c |>
|-> c
choice = 1
| h:
h!
| h from #p:
h!from(#p)
:i = "i"!script($_)
| a |>
|-> a
#p!checkpoint
| aa |>
|-> aa
| ab |>
|-> ab
| b |>
|-> b
1 ~
| c |>
|-> c
| i:
i!
| i from #p:
i!from(#p)

View file

@ -0,0 +1,21 @@
:f = "f"!script($_)
1 ~
#p!checkpoint
|x
~
|y
f!
f!from(#p)
:g = "g"!script($_)
() ~
#p!checkpoint
|x
~
|y
g!
g!from(#p)