Skip to content

Commit

Permalink
Merge pull request #485 from tototoshi/add-test-case-for-by-name
Browse files Browse the repository at this point in the history
Add a testcase for By-name parameters
  • Loading branch information
mergify[bot] authored Jan 30, 2022
2 parents e59c026 + 8107cac commit 91d7d6a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions compiler/src/test/resources/callByName.scala.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@(name: => String)

<h1>Hello @name!</h1>
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,16 @@ class CompilerSpec extends AnyWordSpec with Matchers {
text must be("123456")
}

"compile successfully (call by name)" in {
val helper = newCompilerHelper
val text = helper
.compile[((=> String) => Html)]("callByName.scala.html", "html.callByName")
.static("World")
.toString
.trim
text must be("<h1>Hello World!</h1>")
}

"fail compilation for error.scala.html" in {
val helper = newCompilerHelper
the[CompilationError] thrownBy helper.compile[(() => Html)]("error.scala.html", "html.error") must have(
Expand Down

0 comments on commit 91d7d6a

Please sign in to comment.