lean4-htt/tests/elab/nicerNestedDos.lean
Garmelon 08eb78a5b2
chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

49 lines
718 B
Text

def f (x : Nat) : IO Nat := do
IO.println "hello"
if x > 5 then
IO.println ("x: " ++ toString x)
IO.println "done"
pure (x + 1)
/--
info: hello
---
info: 3
-/
#guard_msgs in
#eval f 2
/--
info: hello
x: 10
done
---
info: 11
-/
#guard_msgs in
#eval f 10
def g (x : Nat) : StateT Nat Id Unit := do
if x > 10 then
let s ← get
set (s + x)
pure ()
theorem ex1 : (g 10).run 1 = ((), 1) :=
rfl
theorem ex2 : (g 20).run 1 = ((), 21) :=
rfl
def h (x : Nat) : StateT Nat Id Unit := do
if x > 10 then {
let s ← get;
set (s + x) -- we don't need to respect indentation when `{` `}` are used
}
pure ()
theorem ex3 : (h 10).run 1 = ((), 1) :=
rfl
theorem ex4 : (h 20).run 1 = ((), 21) :=
rfl