Skip to content

Commit

Permalink
Make script wrapper satisfy compiler checks (#2414)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciejG604 authored Sep 27, 2023
1 parent 8f084ea commit 5ec3f8a
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 // hashCode to clear scalac warning about pure expression in statement position
| }
|}
|""".stripMargin)
Expand Down
Original file line number Diff line number Diff line change
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 5ec3f8a

Please sign in to comment.