add more tests for bridge methods (fake override)

This commit is contained in:
Michael Nedzelsky
2014-10-04 11:44:21 +04:00
parent 2db1d128a0
commit 0c3a7a9d99
6 changed files with 129 additions and 6 deletions
@@ -0,0 +1,26 @@
trait A<T> {
fun foo(t: T): String
}
trait B {
fun foo(t: Int) = "B"
}
class Z1 : A<Int>, B
class Z2 : B, A<Int>
fun box(): String {
val z1 = Z1()
val z2 = Z2()
return when {
z1.foo( 0) != "B" -> "Fail #1"
(z1 : A<Int>).foo( 0) != "B" -> "Fail #2"
(z1 : B).foo( 0) != "B" -> "Fail #3"
z2.foo( 0) != "B" -> "Fail #4"
(z2 : A<Int>).foo( 0) != "B" -> "Fail #5"
(z2 : B).foo( 0) != "B" -> "Fail #6"
else -> "OK"
}
}
@@ -0,0 +1,26 @@
trait A<T> {
fun foo(t: T): String
}
trait B<T : Number> {
fun foo(a: T) = "B"
}
class Z1 : A<Int>, B<Int>
class Z2 : B<Int>, A<Int>
fun box(): String {
val z1 = Z1()
val z2 = Z2()
return when {
z1.foo( 0) != "B" -> "Fail #1"
(z1 : A<Int>).foo( 0) != "B" -> "Fail #2"
(z1 : B<Int>).foo( 0) != "B" -> "Fail #3"
z2.foo( 0) != "B" -> "Fail #4"
(z2 : A<Int>).foo( 0) != "B" -> "Fail #5"
(z2 : B<Int>).foo( 0) != "B" -> "Fail #6"
else -> "OK"
}
}
@@ -0,0 +1,28 @@
trait A<T> {
fun foo(t: T): String
}
trait B {
fun foo(t: Int) = "B"
}
class Z : B
class Z1 : A<Int>, B by Z()
class Z2 : B by Z(), A<Int>
fun box(): String {
val z1 = Z1()
val z2 = Z2()
return when {
z1.foo( 0) != "B" -> "Fail #1"
(z1 : A<Int>).foo( 0) != "B" -> "Fail #2"
(z1 : B).foo( 0) != "B" -> "Fail #3"
z2.foo( 0) != "B" -> "Fail #4"
(z2 : A<Int>).foo( 0) != "B" -> "Fail #5"
(z2 : B).foo( 0) != "B" -> "Fail #6"
else -> "OK"
}
}
@@ -6,17 +6,24 @@ trait B<T, U> {
fun foo(t: T, u: U) = "B"
}
class Z : A<String>, B<String, Int> {
override fun foo(t: String, u: Int) = "Z"
class Z1 : A<String>, B<String, Int> {
override fun foo(t: String, u: Int) = "Z1"
}
class Z2 : B<String, Int>, A<String> {
override fun foo(t: String, u: Int) = "Z2"
}
fun box(): String {
val z = Z()
val z1 = Z1()
val z2 = Z2()
return when {
z.foo("", 0) != "Z" -> "Fail #1"
(z : A<String>).foo("", 0) != "Z" -> "Fail #2"
(z : B<String, Int>).foo("", 0) != "Z" -> "Fail #3"
z1.foo("", 0) != "Z1" -> "Fail #1"
(z1 : A<String>).foo("", 0) != "Z1" -> "Fail #2"
(z1 : B<String, Int>).foo("", 0) != "Z1" -> "Fail #3"
z2.foo("", 0) != "Z2" -> "Fail #4"
(z2 : A<String>).foo("", 0) != "Z2" -> "Fail #5"
(z2 : B<String, Int>).foo("", 0) != "Z2" -> "Fail #6"
else -> "OK"
}
}
@@ -374,12 +374,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("fakeGenericContravariantOverride1.kt")
public void testFakeGenericContravariantOverride1() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericContravariantOverride1.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericContravariantOverride2.kt")
public void testFakeGenericContravariantOverride2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericContravariantOverride2.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericCovariantOverride.kt")
public void testFakeGenericCovariantOverride() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericCovariantOverride.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericCovariantOverrideWithDelegation.kt")
public void testFakeGenericCovariantOverrideWithDelegation() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt");
doTest(fileName);
}
@TestMetadata("fakeOverrideInTraitWithRequiredFromTraitImpl.kt")
public void testFakeOverrideInTraitWithRequiredFromTraitImpl() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeOverrideInTraitWithRequiredFromTraitImpl.kt");
@@ -81,12 +81,30 @@ public class BridgeTestGenerated extends AbstractBridgeTest {
doTest(fileName);
}
@TestMetadata("fakeGenericContravariantOverride1.kt")
public void testFakeGenericContravariantOverride1() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericContravariantOverride1.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericContravariantOverride2.kt")
public void testFakeGenericContravariantOverride2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericContravariantOverride2.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericCovariantOverride.kt")
public void testFakeGenericCovariantOverride() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericCovariantOverride.kt");
doTest(fileName);
}
@TestMetadata("fakeGenericCovariantOverrideWithDelegation.kt")
public void testFakeGenericCovariantOverrideWithDelegation() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeGenericCovariantOverrideWithDelegation.kt");
doTest(fileName);
}
@TestMetadata("fakeOverrideInTraitWithRequiredFromTraitImpl.kt")
public void testFakeOverrideInTraitWithRequiredFromTraitImpl() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/bridges/fakeOverrideInTraitWithRequiredFromTraitImpl.kt");