File tree 3 files changed +34
-0
lines changed
presentation-compiler/test/dotty/tools/pc
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
3
3
import dotty .tools .pc .base .BaseCompletionSuite
4
4
5
5
import org .junit .Test
6
+ import org .junit .Before
6
7
import java .nio .file .Path
8
+ import dotty .tools .pc .utils .JRE
7
9
8
10
class CompletionRelease11Suite extends BaseCompletionSuite :
9
11
10
12
override protected def scalacOptions (classpath : Seq [Path ]): Seq [String ] =
11
13
" -release:11" +: super .scalacOptions(classpath)
12
14
15
+ @ Before
16
+ def beforeMethod (): Unit =
17
+ org.junit.Assume .assumeTrue(JRE .getJavaMajorVersion >= 11 )
18
+
13
19
@ Test def java11Symbols =
14
20
check(
15
21
"""
Original file line number Diff line number Diff line change @@ -3,13 +3,19 @@ package dotty.tools.pc.tests.completion
3
3
import dotty .tools .pc .base .BaseCompletionSuite
4
4
5
5
import org .junit .Test
6
+ import org .junit .Before
6
7
import java .nio .file .Path
8
+ import dotty .tools .pc .utils .JRE
7
9
8
10
class CompletionRelease8Suite extends BaseCompletionSuite :
9
11
10
12
override protected def scalacOptions (classpath : Seq [Path ]): Seq [String ] =
11
13
" -release:8" +: super .scalacOptions(classpath)
12
14
15
+ @ Before
16
+ def beforeMethod (): Unit =
17
+ org.junit.Assume .assumeTrue(JRE .getJavaMajorVersion >= 8 )
18
+
13
19
@ Test def noJvm11Symbols =
14
20
check(
15
21
"""
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