Skip to content

Commit

Permalink
Add scala 2.13 compiler settings test (#1516)
Browse files Browse the repository at this point in the history
Enable settings tests for any 2.12 versions.

This is a follow up of this conversation
#1484 (review)
I had previously with @lefou.

Tested with `mill -i -w
'amm.repl[{2.12.19,2.13.14,3.4.2}].test.testOnly' --
'ammonite.session.BuiltinTests.settings'` so all `2.12`, `2.13` and `3`
latest versions are passing.

Pull request: #1516
  • Loading branch information
carlosrogue authored Jul 17, 2024
1 parent 23a8ef6 commit 23a07fd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions amm/repl/src/test/scala/ammonite/session/BuiltinTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ object BuiltinTests extends TestSuite {
// not sure why that one doesn't pass in 2.13
// even disabling the noimports and imports settings instead of setting noimports to false
// doesn't seem to reinstate imports
def sv = scala.util.Properties.versionNumberString
// In 2.12.13, I would have expected things like
// interp.configureCompiler(_.settings.Wconf.tryToSet(List("any:wv", "cat=unchecked:ws")))
// to re-instate the expected warning below, to no avail :|
if (TestUtils.scala2_12 && sv.stripPrefix("2.12.").toInt <= 19) {
// if 2.12.19 > fails re add condition: scala.util.Properties.versionNumberString.stripPrefix("2.12.").toInt <= 19
if (TestUtils.scala2_12) {
check.session(s"""
@ // Disabling default Scala imports

Expand Down Expand Up @@ -193,12 +193,16 @@ object BuiltinTests extends TestSuite {
@ repl.compiler.settings.nowarnings.value
res10: Boolean = false
""")
} else if (!check.scala2) {
check.session("""
} else {
val configCompiler = if (check.scala2)
"""@ interp.configureCompiler(_.settings.language.tryToSet(List("dynamics")))"""
else
"""@ interp.preConfigureCompiler(ctx => ctx.setSetting(ctx.settings.language, List("dynamics")))"""
check.session(s"""
@ object X extends Dynamic
error: extension of type scala.Dynamic needs to be enabled

@ interp.preConfigureCompiler(ctx => ctx.setSetting(ctx.settings.language, List("dynamics")))
$configCompiler

@ object X extends Dynamic
defined object X
Expand Down

0 comments on commit 23a07fd

Please sign in to comment.