Many of our tests in `tests/lean/run/` produce output from `#eval` (or `#check`) statements, that is then ignored. This PR tries to capture all the useful output using `#guard_msgs`. I've only done a cursory check that the output is still sane --- there is a chance that some "unchecked" tests have already accumulated regressions and this just cements them! In the other direction, I did identify two rotten tests: * a minor one in `setStructInstNotation.lean`, where a comment says `Set Nat`, but `#check` actually prints `?_`. Weird? * `CompilerProbe.lean` is generating empty output, apparently indicating that something is broken, but I don't know the signficance of this file. In any case, I'll ask about these elsewhere. (This started by noticing that a recent `grind` test file had an untested `trace_state`, and then got carried away.)
48 lines
837 B
Text
48 lines
837 B
Text
--
|
|
|
|
structure Payload :=
|
|
(key : Nat)
|
|
(val : Nat)
|
|
|
|
|
|
|
|
@[noinline] def get? (p : Payload) (k : Nat) : Option Nat :=
|
|
if p.key == k then pure p.val else failure
|
|
|
|
inductive T
|
|
| a (i : Nat)
|
|
| b (i : Nat)
|
|
| c (i : Nat)
|
|
| d (i : Nat)
|
|
|
|
@[noinline] def foo (p : Payload) : Option T :=
|
|
(do
|
|
let i ← get? p 1;
|
|
pure (T.a i))
|
|
<|> (do
|
|
let i ← get? p 2;
|
|
pure (T.b i))
|
|
<|> (do
|
|
let i ← get? p 3;
|
|
pure (T.c i))
|
|
<|> (do
|
|
let i ← get? p 4;
|
|
let i ← get? p 5;
|
|
pure (T.d i))
|
|
|
|
def wrongOutput : String :=
|
|
match foo (Payload.mk 1 20) with
|
|
| some (t : T) =>
|
|
match t with
|
|
| T.a i => "1: " ++ toString i
|
|
| T.b i => "2: " ++ toString i
|
|
| T.c i => "3: " ++ toString i
|
|
| T.d i => "4: " ++ toString i
|
|
| none => "5"
|
|
|
|
/-- info: "1: 20" -/
|
|
#guard_msgs in
|
|
#eval wrongOutput
|
|
|
|
def main (xs : List String) : IO Unit :=
|
|
IO.println wrongOutput
|