Skip to content

Commit ce392ba

Browse files
committed
Cleanup compiler test. remove unnecessary isJavaAtLeast conditions
1 parent 9f94dc2 commit ce392ba

File tree

13 files changed

+9
-24
lines changed

13 files changed

+9
-24
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class CompilationTests {
3030

3131
@Test def pos: Unit = {
3232
implicit val testGroup: TestGroup = TestGroup("compilePos")
33-
var tests = List(
33+
val tests = List(
3434
compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init", "-Wunused:all", "-Wshadow:private-shadow", "-Wshadow:type-parameter-shadow"), FileFilter.include(TestSources.posLintingAllowlist)),
3535
compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init"), FileFilter.exclude(TestSources.posLintingAllowlist)),
3636
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
@@ -45,14 +45,14 @@ class CompilationTests {
4545
// Run tests for legacy lazy vals
4646
compileFilesInDir("tests/pos", defaultOptions.and("-Wsafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
4747
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
48+
compileFilesInDir("tests/pos/java-records", defaultOptions.and("-Wsafe-init")),
49+
compileFilesInDir("tests/pos/i19386", defaultOptions.and("-Wsafe-init"))
4850
) ::: (
4951
// TODO create a folder for capture checking tests with the stdlib, or use tests/pos-custom-args/captures under this mode?
5052
if Properties.usingScalaLibraryCCTasty then List(compileDir("tests/pos-special/stdlib", allowDeepSubtypes))
5153
else Nil
5254
)
5355

54-
if scala.util.Properties.isJavaAtLeast("16") then
55-
tests ::= compileFilesInDir("tests/pos-java16+", defaultOptions.and("-Wsafe-init"))
5656

5757
aggregateTests(tests*).checkCompile()
5858
}

compiler/test/dotty/tools/dotc/classpath/MultiReleaseJarTest.scala

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
1919

2020
@Test
2121
def mrJar(): Unit = {
22-
if (!Properties.isJavaAtLeast("9")) { println("skipping mrJar() on old JDK"); return }
2322

2423
// The test fails if the same jar file gets reused. This might be a caching problem in our classpath implementation
2524

@@ -61,8 +60,7 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
6160
assertEquals(Set("foo1", "bar1"), apiMethods(jar1, "8"))
6261
assertEquals(Set("foo1", "foo2", "bar1"), apiMethods(jar2, "9"))
6362

64-
if Properties.isJavaAtLeast("10") then
65-
assertEquals(Set("foo1", "foo2", "bar1", "bar2"), apiMethods(jar3, "10"))
63+
assertEquals(Set("foo1", "foo2", "bar1", "bar2"), apiMethods(jar3, "10"))
6664
} finally
6765
List(jar1, jar2, jar3).forall(path =>
6866
try Files.deleteIfExists(path)
@@ -72,7 +70,6 @@ class MultiReleaseJarTest extends dotty.tools.backend.jvm.DottyBytecodeTest {
7270

7371
@Test
7472
def ctSymTest(): Unit = {
75-
if (!Properties.isJavaAtLeast("9")) { println("skipping mrJar() on old JDK"); return }
7673

7774
def classExists(className: String, release: String): Boolean = {
7875
given ctx: Context = initCtx.fresh

compiler/test/dotty/tools/io/ZipArchiveTest.scala

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import java.io.IOException
66
import java.net.{URI, URL, URLClassLoader}
77
import java.nio.file.{Files, Path, Paths}
88
import java.util.jar.{Attributes, Manifest, JarEntry, JarOutputStream}
9-
import java.lang.invoke.{MethodHandles, MethodType}
109

1110
import org.junit.Assert._
1211
import org.junit.Test
@@ -46,22 +45,11 @@ class ZipArchiveTest {
4645
}
4746

4847
private val bootClassLoader: ClassLoader = {
49-
if (!util.Properties.isJavaAtLeast("9")) null
50-
else {
51-
try {
52-
MethodHandles
53-
.lookup()
54-
.findStatic(
55-
classOf[ClassLoader],
56-
"getPlatformClassLoader",
57-
MethodType.methodType(classOf[ClassLoader])
58-
)
59-
.invoke()
60-
.asInstanceOf[ClassLoader]
61-
} catch {
62-
case _: Throwable =>
63-
null
64-
}
48+
try {
49+
ClassLoader.getPlatformClassLoader
50+
} catch {
51+
case _: Throwable =>
52+
null
6553
}
6654
}
6755

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)