Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a testcase for By-name parameters #485

Merged
merged 2 commits into from
Jan 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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