flan/test/programs/dyn-field-trap.fln

24 lines
589 B
Plaintext

;;;; A dyn's .field and [:key] trap with get's and put's own sentences, one
;;;; per run. The argument chooses which; the test asserts the line numbers.
defclass(State, [paused bool step bool])
fn as-dyn(d) -> dyn = d
fn main(args: [string]) -> i32
let which =
if length(args) > 1 then i32(bytes->i64(bytes-view(args[1]))) else 0
let s = State(false, false)
let n = as-dyn(3)
println("before")
if which == 0
println(n.paused)
elif which == 1
s.paused = 1
elif which == 2
n.paused = true
elif which == 3
s[:step] = 2
else
println(n[:paused])
0