Added tests on default arguments of fake overridden functions

This commit is contained in:
Igor Chevdar
2018-02-15 18:26:45 +03:00
parent a648b9676c
commit a2897a29b5
6 changed files with 186 additions and 0 deletions
@@ -0,0 +1,42 @@
// IGNORE_BACKEND: JVM, JS
interface I<T> {
val prop: T
fun f(x: String = "1"): String
fun g(x: String = "2"): String
fun h(x: T = prop): T
}
interface I2<T> : I<T>
open class A<T> {
open fun f(x: String) = x
open fun g(x: T) = x
open fun h(x: String) = x
}
class B : A<String>(), I2<String> {
override val prop
get() = "3"
}
fun box(): String {
val i: I<String> = B()
var result = i.f() + i.g() + i.h()
if (result != "123") return "fail1: $result"
val b = B()
result = b.f() + b.g() + b.h()
if (result != "123") return "fail2: $result"
val a: A<String> = B()
result = a.f("q") + a.g("w") + a.h("e")
if (result != "qwe") return "fail3: $result"
return "OK"
}
@@ -0,0 +1,48 @@
// IGNORE_BACKEND: JVM, JS
interface I<T> {
val prop: T
fun f(x: String = "1"): String
fun g(x: String = "2"): String
fun h(x: T = prop): T
}
interface I2<T> : I<T> {
override fun f(x: String): String
override fun g(x: String): String
override fun h(x: T): T
}
open class A<T> {
open fun f(x: String) = x
open fun g(x: T) = x
open fun h(x: String) = x
}
class B : A<String>(), I2<String> {
override val prop
get() = "3"
}
fun box(): String {
val i: I<String> = B()
var result = i.f() + i.g() + i.h()
if (result != "123") return "fail1: $result"
val b = B()
result = b.f() + b.g() + b.h()
if (result != "123") return "fail2: $result"
val a: A<String> = B()
result = a.f("q") + a.g("w") + a.h("e")
if (result != "qwe") return "fail3: $result"
return "OK"
}
@@ -7122,6 +7122,30 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake2.kt")
public void testImplementedByFake2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake3.kt")
public void testImplementedByFake3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt")
public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt");
@@ -7122,6 +7122,30 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake2.kt")
public void testImplementedByFake2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake3.kt")
public void testImplementedByFake3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt")
public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt");
@@ -7118,6 +7118,30 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake2.kt")
public void ignoreImplementedByFake2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake3.kt")
public void ignoreImplementedByFake3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
public void testAllFilesPresentInDefaultArguments() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/defaultArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true);
}
@@ -7746,6 +7746,30 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
doTest(fileName);
}
@TestMetadata("implementedByFake2.kt")
public void testImplementedByFake2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake2.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("implementedByFake3.kt")
public void testImplementedByFake3() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/implementedByFake3.kt");
try {
doTest(fileName);
}
catch (Throwable ignore) {
return;
}
throw new AssertionError("Looks like this test can be unmuted. Remove IGNORE_BACKEND directive for that.");
}
@TestMetadata("inheritedFromInterfaceViaAbstractSuperclass.kt")
public void testInheritedFromInterfaceViaAbstractSuperclass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/defaultArguments/inheritedFromInterfaceViaAbstractSuperclass.kt");