Add FULL_JDK to tests in codegen/boxWithStdlib/fullJdk/

Drop the old scheme which relied on the directory name
This commit is contained in:
Alexander Udalov
2016-03-03 14:25:35 +03:00
parent dc085c45b7
commit d011fa8dc6
40 changed files with 119 additions and 89 deletions
@@ -1,2 +0,0 @@
fun box(): String =
listOf("a").map { "OK" }.get(0)
@@ -1,3 +1,5 @@
// FULL_JDK
import java.nio.CharBuffer import java.nio.CharBuffer
fun box(): String { fun box(): String {
@@ -1,3 +1,5 @@
// FULL_JDK
import sun.nio.cs.ext.Big5 import sun.nio.cs.ext.Big5
import sun.net.spi.nameservice.dns.DNSNameService import sun.net.spi.nameservice.dns.DNSNameService
import javax.crypto.Cipher import javax.crypto.Cipher
@@ -1,3 +1,5 @@
// FULL_JDK
@file:JvmName("XYZ") @file:JvmName("XYZ")
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
@@ -1,4 +1,4 @@
import java.lang.Runtime // FULL_JDK
fun box() : String { fun box() : String {
val processors = Runtime.getRuntime()!!.availableProcessors() val processors = Runtime.getRuntime()!!.availableProcessors()
@@ -1,3 +1,5 @@
// FULL_JDK
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
@@ -1,3 +1,5 @@
// FULL_JDK
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
import kotlin.reflect.KProperty import kotlin.reflect.KProperty
@@ -1,3 +1,5 @@
// FULL_JDK
import java.util.LinkedList import java.util.LinkedList
fun ok1(): Boolean { fun ok1(): Boolean {
@@ -1,3 +1,5 @@
// FULL_JDK
import java.net.* import java.net.*
fun String.decodeURI(encoding : String) : String? = fun String.decodeURI(encoding : String) : String? =
@@ -1,3 +1,5 @@
// FULL_JDK
import java.lang.reflect.Modifier import java.lang.reflect.Modifier
public class A { public class A {
@@ -19,7 +21,7 @@ public class A {
return if (cond.isEmpty()) "OK" else cond.joinToString() return if (cond.isEmpty()) "OK" else cond.joinToString()
} }
return "EXCEPTION WAS NOT CATCHED" return "EXCEPTION WAS NOT CAUGHT"
} }
} }
@@ -1,6 +1,6 @@
package foo // FULL_JDK
import kotlin.jvm.* package foo
object ObjWithNative { object ObjWithNative {
external fun foo(x: Int = 1): Double external fun foo(x: Int = 1): Double
@@ -1,3 +1,5 @@
// FULL_JDK
class C { class C {
companion object { companion object {
val defaultGetter: Int = 1 val defaultGetter: Int = 1
@@ -1,4 +1,4 @@
import kotlin.jvm.* // FULL_JDK
class C { class C {
companion object { companion object {
@@ -1,3 +1,5 @@
// FULL_JDK
package foo package foo
import kotlin.jvm.* import kotlin.jvm.*
@@ -1,6 +1,6 @@
package foo // FULL_JDK
import kotlin.jvm.* package foo
class WithNative { class WithNative {
companion object { companion object {
@@ -1,6 +1,6 @@
package foo // FULL_JDK
import kotlin.jvm.* package foo
external fun bar(l: Long, s: String): Double external fun bar(l: Long, s: String): Double
@@ -1,3 +1,5 @@
// FULL_JDK
import java.util.* import java.util.*
fun box(): String { fun box(): String {
@@ -1,3 +1,5 @@
// FULL_JDK
package collections package collections
import kotlin.test.assertEquals import kotlin.test.assertEquals
@@ -1,3 +1,5 @@
// FULL_JDK
package testeval package testeval
import java.util.* import java.util.*
@@ -1,3 +1,5 @@
// FULL_JDK
package pack package pack
import java.util.ArrayList import java.util.ArrayList
@@ -1,3 +1,5 @@
// FULL_JDK
import org.w3c.dom.Element import org.w3c.dom.Element
import org.xml.sax.InputSource import org.xml.sax.InputSource
import javax.xml.parsers.DocumentBuilderFactory import javax.xml.parsers.DocumentBuilderFactory
@@ -1,4 +1,4 @@
import kotlin.* // FULL_JDK
fun box() : String { fun box() : String {
val vector = java.util.Vector<Int>() val vector = java.util.Vector<Int>()
@@ -1,3 +1,5 @@
// FULL_JDK
package mask package mask
import java.io.* import java.io.*
@@ -1,3 +1,5 @@
// FULL_JDK
package mask package mask
import java.io.* import java.io.*
@@ -1,3 +1,5 @@
// FULL_JDK
package mask package mask
import java.io.* import java.io.*
@@ -1,3 +1,5 @@
// FULL_JDK
import kotlin.test.assertEquals import kotlin.test.assertEquals
import java.lang.reflect.ParameterizedType import java.lang.reflect.ParameterizedType
import java.lang.reflect.Type import java.lang.reflect.Type
@@ -1,3 +1,5 @@
// FULL_JDK
import java.io.* import java.io.*
import java.util.* import java.util.*
@@ -1,3 +1,5 @@
// FULL_JDK
fun testProperLineNumber(): String { fun testProperLineNumber(): String {
var exceptionCount = 0; var exceptionCount = 0;
try { try {
@@ -9,7 +11,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1) val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1)
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:6" != actual) { if ("chainCalls.kt:8" != actual) {
return "fail 1: ${actual}" return "fail 1: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -23,7 +25,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:21" != actual) { if ("chainCalls.kt:23" != actual) {
return "fail 2: ${actual}" return "fail 2: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -36,7 +38,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:34" != actual) { if ("chainCalls.kt:36" != actual) {
return "fail 3: ${actual}" return "fail 3: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -48,7 +50,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("chainCalls.kt:46" != actual) { if ("chainCalls.kt:48" != actual) {
return "fail 4: ${actual}" return "fail 4: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -1,3 +1,5 @@
// FULL_JDK
fun testProperLineNumber(): String { fun testProperLineNumber(): String {
var exceptionCount = 0; var exceptionCount = 0;
try { try {
@@ -7,7 +9,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1) val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1)
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:4" != actual) { if ("infixCalls.kt:6" != actual) {
return "fail 1: ${actual}" return "fail 1: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -20,7 +22,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:17" != actual) { if ("infixCalls.kt:19" != actual) {
return "fail 1: ${actual}" return "fail 1: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -32,7 +34,7 @@ fun testProperLineNumber(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("infixCalls.kt:30" != actual) { if ("infixCalls.kt:32" != actual) {
return "fail 1: ${actual}" return "fail 1: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -1,3 +1,5 @@
// FULL_JDK
fun testProperLineNumberAfterInline(): String { fun testProperLineNumberAfterInline(): String {
var exceptionCount = 0; var exceptionCount = 0;
try { try {
@@ -7,7 +9,7 @@ fun testProperLineNumberAfterInline(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1) val entry = (e as java.lang.Throwable).getStackTrace()!!.get(1)
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:4" != actual) { if ("simpleCallWithParams.kt:6" != actual) {
return "fail 1: ${actual}" return "fail 1: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -20,7 +22,7 @@ fun testProperLineNumberAfterInline(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:17" != actual) { if ("simpleCallWithParams.kt:19" != actual) {
return "fail 2: ${actual}" return "fail 2: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -38,7 +40,7 @@ fun testProperLineForOtherParameters(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:35" != actual) { if ("simpleCallWithParams.kt:37" != actual) {
return "fail 3: ${actual}" return "fail 3: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -52,7 +54,7 @@ fun testProperLineForOtherParameters(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:49" != actual) { if ("simpleCallWithParams.kt:51" != actual) {
return "fail 4: ${actual}" return "fail 4: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -64,7 +66,7 @@ fun testProperLineForOtherParameters(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:62" != actual) { if ("simpleCallWithParams.kt:64" != actual) {
return "fail 5: ${actual}" return "fail 5: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -76,7 +78,7 @@ fun testProperLineForOtherParameters(): String {
catch(e: AssertionError) { catch(e: AssertionError) {
val entry = e.stackTrace!![1] val entry = e.stackTrace!![1]
val actual = "${entry.getFileName()}:${entry.getLineNumber()}" val actual = "${entry.getFileName()}:${entry.getLineNumber()}"
if ("simpleCallWithParams.kt:74" != actual) { if ("simpleCallWithParams.kt:76" != actual) {
return "fail 6: ${actual}" return "fail 6: ${actual}"
} }
exceptionCount++ exceptionCount++
@@ -1,3 +1,5 @@
// FULL_JDK
fun box(): String { fun box(): String {
var obj0 = "0" as java.lang.Object var obj0 = "0" as java.lang.Object
var obj1 = "1" as java.lang.Object var obj1 = "1" as java.lang.Object
@@ -1,3 +1,5 @@
// FULL_JDK
fun box(): String { fun box(): String {
val obj = "" as java.lang.Object val obj = "" as java.lang.Object
@@ -1,3 +1,5 @@
// FULL_JDK
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import java.util.concurrent.Executors import java.util.concurrent.Executors
@@ -174,5 +176,3 @@ fun box(): String {
} }
return "OK" return "OK"
} }
@@ -1,3 +1,5 @@
// FULL_JDK
import java.util.concurrent.* import java.util.concurrent.*
import java.util.concurrent.atomic.* import java.util.concurrent.atomic.*
@@ -1,3 +1,5 @@
// FULL_JDK
fun box(): String { fun box(): String {
val obj = "" as java.lang.Object val obj = "" as java.lang.Object
try { try {
@@ -72,8 +72,12 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
FilesKt.readText(new File(filename), Charsets.UTF_8), "NO_KOTLIN_REFLECT" FilesKt.readText(new File(filename), Charsets.UTF_8), "NO_KOTLIN_REFLECT"
) ? ConfigurationKind.NO_KOTLIN_REFLECT : ConfigurationKind.ALL; ) ? ConfigurationKind.NO_KOTLIN_REFLECT : ConfigurationKind.ALL;
TestJdkKind jdkKind = isFullJdkDirectiveDefined(FilesKt.readText(new File(filename), Charsets.UTF_8))
? TestJdkKind.FULL_JDK
: TestJdkKind.MOCK_JDK;
myEnvironment = KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea( myEnvironment = KotlinTestUtils.createEnvironmentWithJdkAndNullabilityAnnotationsFromIdea(
getTestRootDisposable(), configurationKind, getTestJdkKind(filename) getTestRootDisposable(), configurationKind, jdkKind
); );
blackBoxFileByFullPath(filename); blackBoxFileByFullPath(filename);
@@ -137,17 +141,6 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase {
return javaFilePaths; return javaFilePaths;
} }
// NOTE: tests under fullJdk/ are run with FULL_JDK instead of MOCK_JDK
@NotNull
private static TestJdkKind getTestJdkKind(@NotNull String sourcePath) {
if (sourcePath.contains("compiler/testData/codegen/boxWithStdlib/fullJdk")) {
return TestJdkKind.FULL_JDK;
}
String content = FilesKt.readText(new File(sourcePath), Charsets.UTF_8);
return isFullJdkDirectiveDefined(content) ? TestJdkKind.FULL_JDK : TestJdkKind.MOCK_JDK;
}
private static boolean isFullJdkDirectiveDefined(@NotNull String content) { private static boolean isFullJdkDirectiveDefined(@NotNull String content) {
return InTextDirectivesUtils.isDirectiveDefined(content, "FULL_JDK"); return InTextDirectivesUtils.isDirectiveDefined(content, "FULL_JDK");
} }
@@ -35,21 +35,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true); KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class AgainstMultifileStdlib extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInAgainstMultifileStdlib() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("useStdlib.kt")
public void testUseStdlib() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/againstMultifileStdlib/useStdlib.kt");
doTestWithStdlib(fileName);
}
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/annotations") @TestMetadata("compiler/testData/codegen/boxWithStdlib/annotations")
@TestDataPath("$PROJECT_ROOT") @TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class) @RunWith(JUnit3RunnerWithInners.class)
@@ -1693,18 +1678,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName); doTestWithStdlib(fileName);
} }
@TestMetadata("genericBackingFieldSignature.kt")
public void testGenericBackingFieldSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/genericBackingFieldSignature.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("genericMethodSignature.kt")
public void testGenericMethodSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/genericMethodSignature.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("ifInWhile.kt") @TestMetadata("ifInWhile.kt")
public void testIfInWhile() throws Exception { public void testIfInWhile() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/ifInWhile.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/ifInWhile.kt");
@@ -1729,12 +1702,6 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName); doTestWithStdlib(fileName);
} }
@TestMetadata("kt2509.kt")
public void testKt2509() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/kt2509.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("kt434.kt") @TestMetadata("kt434.kt")
public void testKt434() throws Exception { public void testKt434() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/kt434.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/fullJdk/kt434.kt");
@@ -3825,6 +3792,18 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName); doTestWithStdlib(fileName);
} }
@TestMetadata("genericBackingFieldSignature.kt")
public void testGenericBackingFieldSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/genericBackingFieldSignature.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("genericMethodSignature.kt")
public void testGenericMethodSignature() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/genericMethodSignature.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("kt5112.kt") @TestMetadata("kt5112.kt")
public void testKt5112() throws Exception { public void testKt5112() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/kt5112.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/reflection/genericSignature/kt5112.kt");
@@ -4537,6 +4516,12 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib(fileName); doTestWithStdlib(fileName);
} }
@TestMetadata("kt2509.kt")
public void testKt2509() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt2509.kt");
doTestWithStdlib(fileName);
}
@TestMetadata("kt2593.kt") @TestMetadata("kt2593.kt")
public void testKt2593() throws Exception { public void testKt2593() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt2593.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/boxWithStdlib/regressions/kt2593.kt");