lean4-htt/tests/lean/run/meta4.lean
Kim Morrison 3a457e6ad6
chore: use #guard_msgs in run tests (#4175)
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.)
2024-05-16 00:38:31 +00:00

52 lines
1.7 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import Lean.Meta
open Lean
open Lean.Meta
def print (msg : MessageData) : MetaM Unit := do
trace[Meta.debug] msg
def checkM (x : MetaM Bool) : MetaM Unit :=
unless (← x) do throwError "check failed"
axiom Ax : forall (α β : Type), α → β → DecidableEq β
set_option trace.Meta.debug true
def tst1 : MetaM Unit := do
let cinfo ← getConstInfo `Ax;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 0);
checkM (pure (!e.hasMVar));
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 1);
checkM (pure e.hasMVar);
checkM (pure e.isForall);
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 5);
checkM (pure e.hasMVar);
checkM (pure e.isForall);
print e;
let (_, _, e) ← forallMetaTelescopeReducing cinfo.type (some 6);
checkM (pure e.hasMVar);
checkM (pure (!e.isForall));
print e;
let (_, _, e') ← forallMetaTelescopeReducing cinfo.type;
print e';
checkM (isDefEq e e');
forallBoundedTelescope cinfo.type (some 0) $ fun xs body => checkM (pure (xs.size == 0));
forallBoundedTelescope cinfo.type (some 1) $ fun xs body => checkM (pure (xs.size == 1));
forallBoundedTelescope cinfo.type (some 6) $ fun xs body => do { print xs; checkM (pure (xs.size == 6)) };
forallBoundedTelescope cinfo.type (some 10) $ fun xs body => do { print xs; checkM (pure (xs.size == 6)) };
pure ()
/--
info: [Meta.debug] (α β : Type) → α → β → DecidableEq β
[Meta.debug] (β : Type) → ?α → β → DecidableEq β
[Meta.debug] (b : ?β) → Decidable (?a = b)
[Meta.debug] Decidable (?a = ?b)
[Meta.debug] Decidable (?a = ?b)
[Meta.debug] #[α, β, a✝¹, a✝, a, b]
[Meta.debug] #[α, β, a✝¹, a✝, a, b]
-/
#guard_msgs in
#eval tst1