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.
39 lines
834 B
Text
39 lines
834 B
Text
import Lean
|
|
|
|
open Lean
|
|
|
|
partial def mkBig : Nat → Expr
|
|
| 0 => mkConst `a
|
|
| (n+1) => mkApp2 (mkConst `f []) (mkBig n) (mkBig n)
|
|
|
|
def replaceTest (e : Expr) : Expr :=
|
|
e.replace $ fun e => match e with
|
|
| Expr.const c _ => if c == `f then mkConst `g else none
|
|
| _ => none
|
|
|
|
#eval replaceTest $ mkBig 4
|
|
|
|
/-- info: Lean.Expr.const `g [] -/
|
|
#guard_msgs in
|
|
#eval (replaceTest $ mkBig 128).getAppFn
|
|
|
|
def findTest (e : Expr) : Option Expr :=
|
|
e.find? $ fun e => match e with
|
|
| Expr.const c _ => c == `g
|
|
| _ => false
|
|
|
|
/-- info: none -/
|
|
#guard_msgs in
|
|
#eval findTest $ mkBig 4
|
|
|
|
/-- info: some (Lean.Expr.const `g []) -/
|
|
#guard_msgs in
|
|
#eval findTest $ replaceTest $ mkBig 4
|
|
|
|
/-- info: none -/
|
|
#guard_msgs in
|
|
#eval findTest $ mkBig 128
|
|
|
|
/-- info: some (Lean.Expr.const `g []) -/
|
|
#guard_msgs in
|
|
#eval findTest $ (replaceTest $ mkBig 128)
|