@@ -567,36 +567,59 @@ trait RunScriptTestDefinitions { _: RunTestDefinitions =>
567
567
}
568
568
}
569
569
570
- test(" script wrappers satisfy strict compiler flags" ) {
571
- val inputs = TestInputs (
572
- os.rel / " strictClassWrapper.sc" ->
573
- """ //> using scala 3.3.1
574
- |//> using options -Werror -Wnonunit-statement -Wunused:all -Wvalue-discard
575
- |//> using options -Yno-experimental -Ysafe-init -deprecation -feature -language:strictEquality
576
- |//> using options -new-syntax -old-syntax -unchecked -no-indent
577
- |
578
- |println(strictObjectWrapper.Foo(42).x)
579
- |""" .stripMargin,
580
- os.rel / " strictObjectWrapper.sc" ->
581
- """ //> using objectWrapper
582
- |//> using scala 3.3.1
583
- |//> using options -Werror -Wnonunit-statement -Wunused:all -Wvalue-discard
584
- |//> using options -Yno-experimental -Ysafe-init -deprecation -feature -language:strictEquality
585
- |//> using options -new-syntax -old-syntax -unchecked -no-indent
586
- |
587
- |case class Foo(x: Int)
588
- |""" .stripMargin
589
- )
590
- inputs.fromRoot { root =>
591
- val p = os.proc(
592
- TestUtil .cli,
593
- " --power" ,
594
- " strictClassWrapper.sc" ,
595
- " strictObjectWrapper.sc"
596
- ).call(cwd = root)
597
- expect(p.out.trim() == " 42" )
570
+ if (actualScalaVersion.startsWith(" 3" ))
571
+ for {
572
+ useObjectWrapper <- Seq (true , false )
573
+ wrapperType = if (useObjectWrapper) " object" else " class"
598
574
}
599
- }
575
+ test(s " $wrapperType script wrapper satisfies strict compiler flags " ) {
576
+ val expectedMessage = " Hello"
577
+ val sourceFileName = " strictClassWrapper.sc"
578
+ TestInputs (
579
+ os.rel / sourceFileName ->
580
+ s """ //> using options -Werror -Wnonunit-statement -Wunused:all -Wvalue-discard
581
+ |//> using options -Yno-experimental -Ysafe-init -deprecation -feature -language:strictEquality
582
+ |//> using options -new-syntax -old-syntax -unchecked -no-indent
583
+ |
584
+ |println(" $expectedMessage")
585
+ | """ .stripMargin
586
+ )
587
+ .fromRoot { root =>
588
+ val wrapperOptions = if (useObjectWrapper) Seq (" --power" , " --object-wrapper" ) else Nil
589
+ val r = os.proc(TestUtil .cli, " run" , sourceFileName, wrapperOptions, extraOptions)
590
+ .call(cwd = root)
591
+ expect(r.out.trim() == expectedMessage)
592
+ }
593
+ }
594
+
595
+ if (actualScalaVersion.startsWith(" 2" ))
596
+ for {
597
+ useObjectWrapper <- Seq (true , false )
598
+ wrapperType = if (useObjectWrapper) " object" else " App"
599
+ }
600
+ test(s " $wrapperType script wrapper satisfies strict compiler flags " ) {
601
+ val expectedMessage = " Hello"
602
+ val sourceFileName = " strictClassWrapper.sc"
603
+ val warningOptions =
604
+ if (actualScalaVersion.startsWith(" 2.13" ))
605
+ Seq (" -Werror" , " -Wdead-code" , " -Wextra-implicit" )
606
+ else Seq (" -Werror" )
607
+ TestInputs (
608
+ os.rel / sourceFileName ->
609
+ s """ //> using options ${warningOptions.mkString(" " )}
610
+ |//> using options -deprecation -feature
611
+ |//> using options -unchecked
612
+ |
613
+ |println(" $expectedMessage")
614
+ | """ .stripMargin
615
+ )
616
+ .fromRoot { root =>
617
+ val wrapperOptions = if (useObjectWrapper) Seq (" --power" , " --object-wrapper" ) else Nil
618
+ val r = os.proc(TestUtil .cli, " run" , sourceFileName, wrapperOptions, extraOptions)
619
+ .call(cwd = root)
620
+ expect(r.out.trim() == expectedMessage)
621
+ }
622
+ }
600
623
601
624
test(" verify drive-relative JAVA_HOME works" ) {
602
625
val java8Home =
0 commit comments