lean4-htt/tests/lean/run/inlineExpr.lean
jrr6 836d7b703a
feat: add labeled subcomponents and helper functions for error messages (#8225)
This PR adds additional infrastructure for error message formatting.
Specifically, it adds convenience formatters for hints and notes,
including the ability to attach code actions to hint messages using a
"Try This"-like widget, along with several convenience formatters for
message data.

---------

Co-authored-by: Joachim Breitner <mail@joachim-breitner.de>
2025-05-07 21:15:27 +00:00

38 lines
873 B
Text

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"
def testShort : MetaM Unit := do
runTest <| .app (.const ``shortFun []) (.const ``shortConst [])
/-- info: Before shortFun shortConst After -/
#guard_msgs in
#eval testShort
opaque functionWithLongName : Nat → Nat
opaque constantWithLongName : Nat
def testLong : MetaM Unit := do
runTest <| .app (.const ``functionWithLongName []) (.const ``constantWithLongName [])
/--
info: Before
functionWithLongName constantWithLongName
After
-/
#guard_msgs in
#eval testLong