Files
lean4/tests/elab_bench/big_deceq.lean
Garmelon 08eb78a5b2 chore: switch to new test/bench suite (#12590)
This PR sets up the new integrated test/bench suite. It then migrates
all benchmarks and some related tests to the new suite. There's also
some documentation and some linting.

For now, a lot of the old tests are left alone so this PR doesn't become
even larger than it already is. Eventually, all tests should be migrated
to the new suite though so there isn't a confusing mix of two systems.
2026-02-25 13:51:53 +00:00

43 lines
1.1 KiB
Lean4
Raw Permalink 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
/-!
Creates an non-recursive inductive data type with n constructors and deriving `BEq`.
-/
set_option Elab.async false
open Lean Elab
open Elab.Command (CommandElab CommandElabM elabCommand)
open Parser.Command
open Parser.Term
-- Create a name.
def strName (s : String) : Name := Name.anonymous |>.str s
def mkCtorStr (idx : Nat) : String := s!"con{idx}"
def mkCtorIdent (idx : Nat) : Ident := mkIdent <| strName <| mkCtorStr idx
/--
`#test_gen name cnt` creates an inductive type with icnt` unary constructors
-/
syntax (name := testGen) (docComment)? "#test_gen" ident num : command -- declare the syntax
@[command_elab testGen]
def testGenImpl: CommandElab := fun stx => do
match stx with
| `(#test_gen $t $con_count) =>
let con_count := con_count.getNat
let cons Array.ofFnM (n := con_count) fun cIdx =>
let con := mkCtorIdent cIdx
`(ctor| | $con:ident : α $t:ident α )
let idecl
-- Create constant case definitions
`(inductive $t:ident (α : Type) : Type where
$cons:ctor*
deriving DecidableEq
)
elabCommand idecl
| _ =>
throwIllFormedSyntax
#time #test_gen T 30