lean4-htt/tests/lean/run/litToCtor.lean
Kyle Miller acb188f11c
feat: apply pp_using_anonymous_constructor attribute (#3735)
This attribute, which was implemented in #3640, is applied to the
following structures: `Sigma`, `PSigma`, `PProd`, `And`, `Subtype`, and
`Fin`. These were given this attribute in Lean 3.
2024-03-22 00:30:36 +00:00

58 lines
780 B
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
open Lean Meta
def test [ToExpr α] (a : α) : MetaM Unit := do
let a := toExpr a
let c ← litToCtor a
check c
IO.println s!"{← ppExpr c}"
assert! (← isDefEq c a)
/--
info: Nat.succ 9
-/
#guard_msgs in
#eval test 10
/--
info: Nat.succ 0
-/
#guard_msgs in
#eval test 1
/--
info: Nat.zero
-/
#guard_msgs in
#eval test 0
/--
info: Int.negSucc 1
-/
#guard_msgs in
#eval test (-2)
/--
info: Int.negSucc 0
-/
#guard_msgs in
#eval test (-1)
/--
info: Int.ofNat 0
-/
#guard_msgs in
#eval test (0 : Int)
/--
info: Int.ofNat 3
-/
#guard_msgs in
#eval test (3 : Int)
/--
info: ⟨3, ⋯⟩
-/
#guard_msgs in
#eval test (3 : Fin 5)
/--
info: ⟨0, ⋯⟩
-/
#guard_msgs in
#eval test (0 : Fin 5)
/--
info: ⟨1, ⋯⟩
-/
#guard_msgs in
#eval test (6 : Fin 5)