Skip to content

Commit

Permalink
Make script wrapper satisfy compiler checks
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejG604 committed Sep 22, 2023
1 parent 3be1555 commit 8862313
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Expand Up @@ -30,7 +30,7 @@ case object ClassCodeWrapper extends CodeWrapper {
|
| def main(args: Array[String]): Unit = {
| args$$set(args)
| script.hashCode() // hashCode to clear scalac warning about pure expression in statement position
| val _ = script.hashCode() // hashCode to clear scalac warning about pure expression in statement position
| }
|}
|
Expand Down
Expand Up @@ -31,7 +31,7 @@ case object ObjectCodeWrapper extends CodeWrapper {
| }
| def main(args: Array[String]): Unit = {
| args$$set(args)
| $funHashCodeMethod // hasCode to clear scalac warning about pure expression in statement position
| val _ = $funHashCodeMethod // hasCode to clear scalac warning about pure expression in statement position
| }
|}
|""".stripMargin)
Expand Down
Expand Up @@ -518,4 +518,31 @@ trait RunScriptTestDefinitions { _: RunTestDefinitions =>
}
}
}

test("script wrappers satisfy strict compiler flags") {
val inputs = TestInputs(
os.rel / "strictClassWrapper.sc" ->
"""//> using scala 3.3.1
|//> using options -Werror -Wnonunit-statement -Wunused:all -Wvalue-discard
|//> using options -Yno-experimental -Ysafe-init -deprecation -feature -language:strictEquality
|//> using options -new-syntax -old-syntax -unchecked -no-indent
|
|println(strictObjectWrapper.Foo(42).x)
|""".stripMargin,

os.rel / "strictObjectWrapper.sc" ->
"""//> using objectWrapper
|//> using scala 3.3.1
|//> using options -Werror -Wnonunit-statement -Wunused:all -Wvalue-discard
|//> using options -Yno-experimental -Ysafe-init -deprecation -feature -language:strictEquality
|//> using options -new-syntax -old-syntax -unchecked -no-indent
|
|case class Foo(x: Int)
|""".stripMargin
)
inputs.fromRoot { root =>
val p = os.proc(TestUtil.cli, "--power", "strictClassWrapper.sc", "strictObjectWrapper.sc").call(cwd = root)
expect(p.out.trim() == "42")
}
}
}

0 comments on commit 8862313

Please sign in to comment.