Skip to content

Commit

Permalink
Wrap code in object instead of a class
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed May 4, 2021
1 parent 179c110 commit 9659667
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ object Instrumenter {
val wrapped = new StringBuilder()
.append("package repl\n")
.append("object MdocSession extends _root_.mdoc.internal.document.DocumentBuilder {\n")
.append(" def app(): _root_.scala.Unit = {val _ = new App()}\n")
.append(" class App {\n")
.append(" def app(): _root_.scala.Unit = { App }\n")
.append(" object App {\n")
.append(body)
.append(" }\n")
.append("}\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ class WorksheetSuite extends BaseSuite {
|""".stripMargin
)

checkDiagnostics(
"value",
"""|object Foo {
| case class Bar(b: Int) extends AnyVal
|}""".stripMargin,
""
)

checkDecorations(
"lazy",
"""
Expand Down Expand Up @@ -226,15 +234,29 @@ class WorksheetSuite extends BaseSuite {
|val filename = "boom"
|crash(filename)
|""".stripMargin,
"""|crash:4:1: error: java.lang.RuntimeException: boom
| at repl.MdocSession$App.crash(crash.scala:8)
| at repl.MdocSession$App.<init>(crash.scala:14)
"""|crash:4:1: error: java.lang.ExceptionInInitializerError
| at repl.MdocSession$.app(crash.scala:3)
|Caused by: java.lang.RuntimeException: boom
| at repl.MdocSession$App$.crash(crash.scala:8)
| at repl.MdocSession$App$.<init>(crash.scala:14)
| at repl.MdocSession$App$.<clinit>(crash.scala)
| ... 1 more
|
|crash(filename)
|^^^^^^^^^^^^^^^
|""".stripMargin,
compat = Map(
"2.13.5" ->
"""|crash:4:1: error: java.lang.ExceptionInInitializerError
| at repl.MdocSession$.app(crash.scala:3)
|Caused by: java.lang.RuntimeException: boom
| at repl.MdocSession$App$.crash(crash.scala:8)
| at repl.MdocSession$App$.<clinit>(crash.scala:14)
| ... 1 more
|
|crash(filename)
|^^^^^^^^^^^^^^^
|""".stripMargin,
"3.0" ->
"""|crash:4:1: error: java.lang.RuntimeException: boom
| at repl.MdocSession$App.crash(crash.scala:8)
Expand Down

0 comments on commit 9659667

Please sign in to comment.