Files
lean4/tests/elab/inlineExpr.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

64 lines
1.6 KiB
Lean4

import Lean.Meta
/-!
# Tests for the `inlineExpr` function
`inlineExpr` should print the given expression inline, unless it exceeds a given length, in which
case it is moved to an indented block.
-/
open Lean Meta
opaque shortFun : Nat Nat
opaque shortConst : Nat
def runTest (e : Expr) : MetaM Unit := do
let msg := inlineExpr e (maxInlineLength := 30)
logInfo m!"Before{msg}After"
/-- info: Before `shortFun shortConst` After -/
#guard_msgs in
#eval runTest <| .app (.const ``shortFun []) (.const ``shortConst [])
opaque functionWithLongName : Nat Nat
opaque constantWithLongName : Nat
/--
info: Before
functionWithLongName constantWithLongName
After
-/
#guard_msgs in
#eval runTest <| .app (.const ``functionWithLongName []) (.const ``constantWithLongName [])
/-! Ensure that length computation accounts for namespace occlusion: -/
namespace ExceptionallyLongNamespaceThatWillNotBePrinted
opaque Bar.Baz : Nat Nat
/--
info: Before `Bar.Baz Nat.zero` After
-/
#guard_msgs in
#eval runTest <| .app (.const ``Bar.Baz []) (.const ``Nat.zero [])
end ExceptionallyLongNamespaceThatWillNotBePrinted
/-! Test `trailing` variant: -/
def runTestTrailing (e : Expr) : MetaM Unit := do
let msg := inlineExprTrailing e (maxInlineLength := 30)
logInfo m!"Before{msg}"
/-- info: Before `shortFun shortConst` -/
#guard_msgs in
#eval runTestTrailing <| .app (.const ``shortFun []) (.const ``shortConst [])
/--
info: Before
functionWithLongName constantWithLongName
-/
#guard_msgs in
#eval runTestTrailing <| .app (.const ``functionWithLongName []) (.const ``constantWithLongName [])