chore: fix tests
This commit is contained in:
parent
68143ca8ba
commit
48b855bfe5
21 changed files with 49 additions and 49 deletions
|
|
@ -262,7 +262,7 @@ def getDeclTypeValueDagSize (declName : Name) : CoreM Nat := do
|
|||
def reduceAndGetDagSize (declName : Name) : MetaM Nat := do
|
||||
let c := mkConst declName [levelOne]
|
||||
let e ← Meta.reduce c
|
||||
trace[Meta.debug]! "{e}"
|
||||
trace[Meta.debug] "{e}"
|
||||
e.dagSize
|
||||
|
||||
#eval reduceAndGetDagSize `test1
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ set_option trace.Meta.debug true
|
|||
|
||||
def printDef (declName : Name) : MetaM Unit := do
|
||||
let cinfo ← getConstInfo declName;
|
||||
trace! `Meta.debug cinfo.value!
|
||||
trace[Meta.debug] cinfo.value!
|
||||
|
||||
def tst1 : MetaM Unit := do
|
||||
let u := mkLevelParam `u
|
||||
|
|
@ -27,7 +27,7 @@ withLocalDeclD `f (← mkArrow α α) $ fun f => do
|
|||
withLetDecl `b α (mkApp f a) $ fun b => do
|
||||
let t := mkApp m2 (mkApp f b)
|
||||
let e ← mkAuxDefinitionFor `foo1 t
|
||||
trace[Meta.debug]! e
|
||||
trace[Meta.debug] e
|
||||
printDef `foo1
|
||||
|
||||
#eval tst1
|
||||
|
|
@ -43,7 +43,7 @@ withLocalDeclD `p (mkSort levelZero) $ fun p => do
|
|||
let t ← mkEq v1 v2
|
||||
let t := mkApp2 (mkConst `And) t (mkApp2 (mkConst `Or) (mkApp m v2) p)
|
||||
let e ← mkAuxDefinitionFor `foo2 t
|
||||
trace! `Meta.debug e
|
||||
trace[Meta.debug] e
|
||||
printDef `foo2
|
||||
|
||||
#eval tst2
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ open Lean.Core
|
|||
def f : CoreM Nat := do
|
||||
let env ← getEnv;
|
||||
let cinfo ← getConstInfo `Nat.add;
|
||||
trace! `Elab "trace message";
|
||||
trace[Elab] "trace message";
|
||||
IO.println $ toString cinfo.type;
|
||||
IO.println "testing...";
|
||||
pure 10;
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ generalizeTelescope majors.toArray fun majors => do
|
|||
def test (ex : Name) (numPats : Nat) (elimName : Name) (inProp : Bool := false) : MetaM Unit :=
|
||||
withDepElimFrom ex numPats fun majors alts => do
|
||||
let majors := majors.map mkFVar
|
||||
trace[Meta.debug]! m!"majors: {majors.toArray}"
|
||||
trace[Meta.debug] m!"majors: {majors.toArray}"
|
||||
let r ← mkTester elimName majors alts inProp
|
||||
unless r.counterExamples.isEmpty do
|
||||
throwError m!"missing cases:\n{counterExamplesToMessageData r.counterExamples}"
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ let vecN1 := mkApp2 (mkConst `Vec) nat n1
|
|||
withLocalDeclD `xs vecN1 fun xs => do
|
||||
generalizeTelescope #[n1, xs] fun ys => do
|
||||
let t ← mkLambdaFVars ys ys.back
|
||||
trace! `Meta.debug t
|
||||
trace[Meta.debug] t
|
||||
pure ()
|
||||
|
||||
#eval tst1
|
||||
|
|
@ -34,7 +34,7 @@ withLocalDeclD `xs vecN1 $ fun xs => do
|
|||
let e ← mkEqRefl xs
|
||||
generalizeTelescope #[n1, xs, e] fun ys => do
|
||||
let t ← mkLambdaFVars ys ys.back
|
||||
trace! `Meta.debug t
|
||||
trace[Meta.debug] t
|
||||
pure ()
|
||||
|
||||
#eval tst2
|
||||
|
|
@ -53,8 +53,8 @@ let e ← mkEqRefl xs
|
|||
failIfSuccess do
|
||||
generalizeTelescope #[n1, e] fun ys => do
|
||||
let t ← mkLambdaFVars ys ys.back
|
||||
trace! `Meta.debug t
|
||||
trace[Meta.debug] t
|
||||
pure ()
|
||||
trace! `Meta.debug "failed as expected"
|
||||
trace[Meta.debug] "failed as expected"
|
||||
|
||||
#eval tst3
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ def tst1 : MetaM Unit := do
|
|||
let cinfo ← getConstInfo `goal;
|
||||
let type := cinfo.type;
|
||||
let mvar ← mkFreshExprMVar type;
|
||||
trace! `Elab (MessageData.ofGoal mvar.mvarId!);
|
||||
trace[Elab] (MessageData.ofGoal mvar.mvarId!);
|
||||
let (_, mvarId) ← introN mvar.mvarId! 2;
|
||||
let (fvarId, mvarId) ← intro1 mvarId;
|
||||
trace! `Elab (MessageData.ofGoal mvarId);
|
||||
trace[Elab] (MessageData.ofGoal mvarId);
|
||||
let s ← generalizeIndices mvarId fvarId;
|
||||
trace! `Elab (MessageData.ofGoal s.mvarId);
|
||||
trace[Elab] (MessageData.ofGoal s.mvarId);
|
||||
pure ()
|
||||
|
||||
set_option trace.Elab true
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ def f (x : Type) := x
|
|||
def tst : MetaM Unit := do
|
||||
let m1 ← mkFreshExprMVar none
|
||||
withLocalDeclD `x m1 fun x => do
|
||||
trace[Meta.debug]! "{x} : {← inferType x}"
|
||||
trace[Meta.debug]! "{m1} : {← inferType m1}"
|
||||
trace[Meta.debug] "{x} : {← inferType x}"
|
||||
trace[Meta.debug] "{m1} : {← inferType m1}"
|
||||
let m2 ← mkFreshExprMVar (mkSort levelOne)
|
||||
let t ← mkAppM ``f #[m2]
|
||||
trace[Meta.debug]! "{m2} : {← inferType m2}"
|
||||
trace[Meta.debug] "{m2} : {← inferType m2}"
|
||||
unless (← fullApproxDefEq <| isDefEq m1 t) do -- m1 := f m3 -- where `m3` has a smaller scope than `m2`
|
||||
throwError! "isDefEq failed"
|
||||
trace[Meta.debug]! "{m2} : {← inferType m2}"
|
||||
trace[Meta.debug]! "{m1} : {← inferType m1}"
|
||||
trace[Meta.debug] "{m2} : {← inferType m2}"
|
||||
trace[Meta.debug] "{m1} : {← inferType m1}"
|
||||
let e ← mkForallFVars #[x] m2 -- `forall (x : f ?m2), ?m2`
|
||||
trace[Meta.debug]! "{e} : {← e}"
|
||||
trace[Meta.debug] "{e} : {← e}"
|
||||
return ()
|
||||
|
||||
set_option trace.Meta.isDefEq true
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ open Lean.Meta
|
|||
set_option trace.Meta.debug true
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def checkM (x : MetaM Bool) : MetaM Unit :=
|
||||
unless (← x) do throwError "check failed"
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ let opt := opt.setBool `trace.Meta true;
|
|||
opt
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def check (x : MetaM Bool) : MetaM Unit :=
|
||||
unless (← x) do throwError "check failed"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ open Lean
|
|||
open Lean.Meta
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def checkM (x : MetaM Bool) : MetaM Unit :=
|
||||
unless (← x) do throwError "check failed"
|
||||
|
|
|
|||
|
|
@ -7,16 +7,16 @@ def tst1 : MetaM Unit :=
|
|||
withLocalDeclD `y (mkConst `Nat) $ fun y => do
|
||||
withLetDecl `x (mkConst `Nat) (mkNatLit 0) $ fun x => do {
|
||||
let mvar ← mkFreshExprMVar (mkConst `Nat) MetavarKind.syntheticOpaque;
|
||||
trace[Meta.debug]! mvar;
|
||||
trace[Meta.debug] mvar;
|
||||
let r ← mkLambdaFVars #[y, x] mvar;
|
||||
trace[Message.debug]! r;
|
||||
trace[Message.debug] r;
|
||||
let v := mkApp2 (mkConst `Nat.add) x y;
|
||||
assignExprMVar mvar.mvarId! v;
|
||||
trace[Meta.debug]! mvar;
|
||||
trace[Meta.debug]! r;
|
||||
trace[Meta.debug] mvar;
|
||||
trace[Meta.debug] r;
|
||||
let mctx ← getMCtx;
|
||||
mctx.decls.forM fun mvarId mvarDecl => do
|
||||
trace[Meta.debug]! m!"?{mvarId} : {mvarDecl.type}"
|
||||
trace[Meta.debug] m!"?{mvarId} : {mvarDecl.type}"
|
||||
}
|
||||
|
||||
set_option trace.Meta.debug true
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ open Lean
|
|||
open Lean.Meta
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def checkM (x : MetaM Bool) : MetaM Unit :=
|
||||
unless (← x) do throwError "check failed"
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ set_option trace.Meta.debug true
|
|||
set_option trace.Meta.check false
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def checkM (x : MetaM Bool) : MetaM Unit :=
|
||||
unless (← x) do throwError "check failed"
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ open Lean
|
|||
open Lean.Meta
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.debug msg
|
||||
trace[Meta.debug] msg
|
||||
|
||||
def showRecInfo (declName : Name) (majorPos? : Option Nat := none) : MetaM Unit := do
|
||||
let info ← mkRecursorInfo declName majorPos?
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ open Lean.Meta
|
|||
|
||||
def tst1 : MetaM Unit := do
|
||||
let lemmas ← Meta.getSimpLemmas
|
||||
trace[Meta.debug]! "{lemmas.pre}\n-----\n{lemmas.post}"
|
||||
trace[Meta.debug] "{lemmas.pre}\n-----\n{lemmas.post}"
|
||||
|
||||
set_option trace.Meta.debug true in
|
||||
#eval tst1
|
||||
|
|
@ -42,10 +42,10 @@ def tst2 : MetaM Unit := do
|
|||
match type.eq? with
|
||||
| none => throwError! "unexpected"
|
||||
| some (_, lhs, _) =>
|
||||
trace[Meta.debug]! "lhs: {lhs}"
|
||||
trace[Meta.debug] "lhs: {lhs}"
|
||||
let s ← Meta.getSimpLemmas
|
||||
let m ← s.post.getMatch lhs
|
||||
trace[Meta.debug]! "result: {m}"
|
||||
trace[Meta.debug] "result: {m}"
|
||||
assert! m.any fun s => s.name? == `ex2
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ instance coerceNatToInt : HasCoerce Nat Int :=
|
|||
⟨fun x => Int.ofNat x⟩
|
||||
|
||||
def print {α} [ToString α] (a : α) : MetaM Unit :=
|
||||
trace! `Meta.synthInstance (toString a)
|
||||
trace[Meta.synthInstance] (toString a)
|
||||
|
||||
|
||||
def tst1 : MetaM Unit := do
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ open Lean.Meta
|
|||
axiom simple : forall {p q : Prop}, p → q → p
|
||||
|
||||
def print (msg : MessageData) : MetaM Unit :=
|
||||
trace! `Meta.Tactic msg
|
||||
trace[Meta.Tactic] msg
|
||||
|
||||
def tst1 : MetaM Unit := do
|
||||
let cinfo ← getConstInfo `simple
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@ structure MyState :=
|
|||
abbrev M := CoreM
|
||||
|
||||
def tst1 : M Unit :=
|
||||
do trace! `module (m!"hello" ++ MessageData.nest 9 (m!"\n" ++ "world"));
|
||||
trace! `module.aux "another message";
|
||||
do trace[module] (m!"hello" ++ MessageData.nest 9 (m!"\n" ++ "world"));
|
||||
trace[module.aux] "another message";
|
||||
pure ()
|
||||
|
||||
def tst2 (b : Bool) : M Unit :=
|
||||
traceCtx `module $ do
|
||||
tst1;
|
||||
trace! `bughunt "at test2";
|
||||
trace[bughunt] "at test2";
|
||||
when b $ throwError "error";
|
||||
tst1;
|
||||
pure ()
|
||||
|
|
@ -34,10 +34,10 @@ do traceCtx `module $ do {
|
|||
tst2 b;
|
||||
tst1
|
||||
};
|
||||
trace! `bughunt "at end of tst3";
|
||||
trace[bughunt] "at end of tst3";
|
||||
-- Messages are computed lazily. The following message will only be computed
|
||||
-- if `trace.slow is active.
|
||||
trace! `slow (m!"slow message: " ++ toString (slow b))
|
||||
trace[slow] (m!"slow message: " ++ toString (slow b))
|
||||
|
||||
def run (x : M Unit) : M Unit :=
|
||||
withReader
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ def tst : MetaM Unit := do
|
|||
let c ← getConstInfo `boo
|
||||
lambdaTelescope c.value! fun xs b => do
|
||||
withReducibleAndInstances do
|
||||
trace[Meta.debug]! "b: {← reduce b}"
|
||||
trace[Meta.debug] "b: {← reduce b}"
|
||||
|
||||
set_option trace.Meta.debug true
|
||||
#eval tst
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ open Lean.Meta
|
|||
def tst (declName : Name) : MetaM Unit := do
|
||||
let c ← getConstInfo declName
|
||||
lambdaTelescope c.value! fun _ b => do
|
||||
trace[Meta.debug]! "1. {b}"
|
||||
trace[Meta.debug]! "2. {← withReducible <| whnf b}"
|
||||
trace[Meta.debug]! "3. {← withReducibleAndInstances <| whnf b}"
|
||||
trace[Meta.debug]! "4. {← withDefault <| whnf b}"
|
||||
trace[Meta.debug] "1. {b}"
|
||||
trace[Meta.debug] "2. {← withReducible <| whnf b}"
|
||||
trace[Meta.debug] "3. {← withReducibleAndInstances <| whnf b}"
|
||||
trace[Meta.debug] "4. {← withDefault <| whnf b}"
|
||||
pure ()
|
||||
|
||||
set_option trace.Meta.debug true
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ open Lean.Meta
|
|||
|
||||
def tst : MetaM Unit := do
|
||||
let info ← getConstInfoInduct `Test.Bla
|
||||
trace[Meta.debug]! "nested: {info.isNested}"
|
||||
trace[Meta.debug] "nested: {info.isNested}"
|
||||
pure ()
|
||||
|
||||
#eval tst
|
||||
|
|
@ -128,7 +128,7 @@ def mkContext (className : Name) (typeName : Name) (resultType : Syntax) (mkAltR
|
|||
match className.eraseMacroScopes, typeName.eraseMacroScopes with
|
||||
| Name.str _ c _, Name.str _ t _ => auxFunNames := auxFunNames.push (← mkFreshUserName <| Name.mkSimple <| c.decapitalize ++ t)
|
||||
| _, _ => auxFunNames := auxFunNames.push (← mkFreshUserName `instFn)
|
||||
trace[Meta.debug]! "{auxFunNames}"
|
||||
trace[Meta.debug] "{auxFunNames}"
|
||||
let usePartial := indVal.isNested || typeInfos.size > 1
|
||||
return {
|
||||
classInfo := classInfo
|
||||
|
|
@ -283,7 +283,7 @@ def mkInstanceCmds (ctx : Context) : TermElabM (Array Syntax) := do
|
|||
let type ← `($(mkIdent ctx.classInfo.name) $indType)
|
||||
let val ← `(⟨$(mkIdent auxFunName)⟩)
|
||||
let instCmd ← `(instance $binders:implicitBinder* : $type := $val)
|
||||
trace[Meta.debug]! "\n{instCmd}"
|
||||
trace[Meta.debug] "\n{instCmd}"
|
||||
instances := instances.push instCmd
|
||||
return instances
|
||||
|
||||
|
|
@ -293,7 +293,7 @@ def mkDeriving (className : Name) (typeName : Name) (resultType : Syntax) (mkAlt
|
|||
let cmds ← liftTermElabM none do
|
||||
let ctx ← mkContext className typeName resultType mkAltRhs
|
||||
let block ← mkMutualBlock ctx
|
||||
trace[Meta.debug]! "\n{block}"
|
||||
trace[Meta.debug] "\n{block}"
|
||||
return #[block] ++ (← mkInstanceCmds ctx)
|
||||
cmds.forM elabCommand
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue