JVM_IR: add a test for when(enum) binary compatibility
This commit is contained in:
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
enum class E1 { A, C, B, D }
|
||||||
|
enum class E2 { A, B }
|
||||||
+4
@@ -0,0 +1,4 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
enum class E1 { A, B, C }
|
||||||
|
enum class E2 { A, B, C }
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
OK
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
import test.*
|
||||||
|
|
||||||
|
fun f1(x: E1) = when (x) {
|
||||||
|
E1.A -> "A"
|
||||||
|
E1.B -> "B"
|
||||||
|
E1.C -> "C"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f2(x: E2) = when (x) {
|
||||||
|
E2.A -> "A"
|
||||||
|
E2.B -> "B"
|
||||||
|
E2.C -> "C"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun run(): String {
|
||||||
|
val c2 = try { f2(E2.C) } catch (e: java.lang.NoSuchFieldError) { "" }
|
||||||
|
return f1(E1.A) + f1(E1.B) + f1(E1.C) + f2(E2.A) + f2(E2.B) + c2
|
||||||
|
}
|
||||||
+11
@@ -519,6 +519,17 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
.loadClass("SourceKt").getDeclaredMethod("run").invoke(null)
|
.loadClass("SourceKt").getDeclaredMethod("run").invoke(null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testChangedEnumsInLibrary() {
|
||||||
|
val oldLibrary = compileLibrary("old", checkKotlinOutput = {})
|
||||||
|
val newLibrary = compileLibrary("new", checkKotlinOutput = {})
|
||||||
|
compileKotlin("source.kt", tmpdir, listOf(oldLibrary))
|
||||||
|
|
||||||
|
val result =
|
||||||
|
URLClassLoader(arrayOf(newLibrary.toURI().toURL(), tmpdir.toURI().toURL()), ForTestCompileRuntime.runtimeJarClassLoader())
|
||||||
|
.loadClass("SourceKt").getDeclaredMethod("run").invoke(null) as String
|
||||||
|
assertEquals("ABCAB", result)
|
||||||
|
}
|
||||||
|
|
||||||
fun testClassFromJdkInLibrary() {
|
fun testClassFromJdkInLibrary() {
|
||||||
val library = compileLibrary("library")
|
val library = compileLibrary("library")
|
||||||
compileKotlin("source.kt", tmpdir, listOf(library))
|
compileKotlin("source.kt", tmpdir, listOf(library))
|
||||||
|
|||||||
Reference in New Issue
Block a user