File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
presentation-compiler/test/dotty/tools/pc Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ package dotty.tools.pc.tests.completion
33import dotty .tools .pc .base .BaseCompletionSuite
44
55import org .junit .Test
6+ import org .junit .Before
67import java .nio .file .Path
8+ import dotty .tools .pc .utils .JRE
79
810class CompletionRelease11Suite extends BaseCompletionSuite :
911
1012 override protected def scalacOptions (classpath : Seq [Path ]): Seq [String ] =
1113 " -release:11" +: super .scalacOptions(classpath)
1214
15+ @ Before
16+ def beforeMethod (): Unit =
17+ org.junit.Assume .assumeTrue(JRE .getJavaMajorVersion >= 11 )
18+
1319 @ Test def java11Symbols =
1420 check(
1521 """
Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ package dotty.tools.pc.tests.completion
33import dotty .tools .pc .base .BaseCompletionSuite
44
55import org .junit .Test
6+ import org .junit .Before
67import java .nio .file .Path
8+ import dotty .tools .pc .utils .JRE
79
810class CompletionRelease8Suite extends BaseCompletionSuite :
911
1012 override protected def scalacOptions (classpath : Seq [Path ]): Seq [String ] =
1113 " -release:8" +: super .scalacOptions(classpath)
1214
15+ @ Before
16+ def beforeMethod (): Unit =
17+ org.junit.Assume .assumeTrue(JRE .getJavaMajorVersion >= 8 )
18+
1319 @ Test def noJvm11Symbols =
1420 check(
1521 """
Original file line number Diff line number Diff line change 1+ package dotty .tools .pc .utils
2+
3+ object JRE :
4+
5+ def getJavaMajorVersion : Int =
6+ val javaVersion = sys.env.get(" java.version" ).filter(! _.isEmpty())
7+
8+ javaVersion match
9+ case Some (version) if version.startsWith(" 1.8" ) => 8
10+ case _ =>
11+ scala.util.Try :
12+ val versionMethod = classOf [Runtime ].getMethod(" version" )
13+ versionMethod.nn.setAccessible(true )
14+ val version = versionMethod.nn.invoke(null )
15+
16+ val majorMethod = version.getClass().getMethod(" feature" )
17+ majorMethod.nn.setAccessible(true )
18+ val major = majorMethod.nn.invoke(version).asInstanceOf [Int ]
19+ major
20+ .getOrElse(8 ) // Minimal version supported by Scala
21+
22+
You can’t perform that action at this time.
0 commit comments