Skip to content

Commit

Permalink
expand test to actually exercise generated instance
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkeizer committed Dec 11, 2024
1 parent 182775a commit 20d4a2c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/lean/run/derivingToExpr.lean
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
import Lean.Elab.Deriving.ToExpr

open Lean (ToExpr)
open Lean

deriving instance ToExpr for ULift

-- Test with a universe polymporphic type parameter
inductive Option' (α : Type u)
| some (a : α)
| none
deriving ToExpr

/-- info: instToExprOption'OfToLevel -/
#guard_msgs in #synth ToExpr (Option' Nat)
/-- info: instToExprOption'OfToLevel -/
#guard_msgs in #synth ToExpr (Option' <| ULift.{20} Nat)

/--
info: Lean.Expr.app
(Lean.Expr.app
(Lean.Expr.const `Option'.some [Lean.Level.succ (Lean.Level.succ (Lean.Level.succ (Lean.Level.zero)))])
(Lean.Expr.app
(Lean.Expr.const `ULift [Lean.Level.succ (Lean.Level.succ (Lean.Level.succ (Lean.Level.zero))), Lean.Level.zero])
(Lean.Expr.const `Nat [])))
(Lean.Expr.app
(Lean.Expr.app
(Lean.Expr.const
`ULift.up
[Lean.Level.succ (Lean.Level.succ (Lean.Level.succ (Lean.Level.zero))), Lean.Level.zero])
(Lean.Expr.const `Nat []))
(Lean.Expr.app
(Lean.Expr.app
(Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat []))
(Lean.Expr.lit (Lean.Literal.natVal 42)))
(Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 42)))))
-/
#guard_msgs in #eval toExpr (Option'.some <| ULift.up.{3} 42)

-- Test with recursive type
inductive List' (α : Type u)
| cons (a : α) (as : List' α)
Expand Down
Empty file.

0 comments on commit 20d4a2c

Please sign in to comment.