KT-2752: add basic tests for JsName

This commit is contained in:
Alexey Andreev
2016-05-30 14:26:24 +03:00
parent 5e3aa33b13
commit 5ce158f297
44 changed files with 300 additions and 157 deletions
@@ -0,0 +1,9 @@
package foo
open class Super {
<!JS_NAME_CLASH!>fun foo() = 23<!>
}
class Sub : Super() {
<!JS_NAME_CLASH!>@JsName("foo") fun bar() = 42<!>
}
@@ -0,0 +1,21 @@
package
package foo {
public final class Sub : foo.Super {
public constructor Sub()
@kotlin.js.JsName(name = "foo") public final fun bar(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public open class Super {
public constructor Super()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,5 @@
package foo
@JsName("bar") fun foo(x: Int) = x
private fun bar() = 42
@@ -0,0 +1,6 @@
package
package foo {
private fun bar(): kotlin.Int
@kotlin.js.JsName(name = "bar") public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
}
@@ -0,0 +1,5 @@
package foo
<!JS_NAME_CLASH!>@JsName("x") fun foo(x: Int) = x<!>
<!JS_NAME_CLASH!>@JsName("x") fun bar() = 42<!>
@@ -0,0 +1,6 @@
package
package foo {
@kotlin.js.JsName(name = "x") public fun bar(): kotlin.Int
@kotlin.js.JsName(name = "x") public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
}
@@ -0,0 +1,5 @@
package foo
<!JS_NAME_CLASH!>@JsName("bar") fun foo(x: Int) = x<!>
<!JS_NAME_CLASH!>fun bar() = 42<!>
@@ -0,0 +1,6 @@
package
package foo {
public fun bar(): kotlin.Int
@kotlin.js.JsName(name = "bar") public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
}
@@ -0,0 +1,5 @@
package foo
<!JS_NAME_CLASH!>@JsName("bar") private fun foo(x: Int) = x<!>
<!JS_NAME_CLASH!>fun bar() = 42<!>
@@ -0,0 +1,6 @@
package
package foo {
public fun bar(): kotlin.Int
@kotlin.js.JsName(name = "bar") private fun foo(/*0*/ x: kotlin.Int): kotlin.Int
}
@@ -0,0 +1,7 @@
package foo
class A(val x: String) {
<!JS_NAME_CLASH!>@JsName("aa") constructor(x: Int) : this("int $x")<!>
}
<!JS_NAME_CLASH!>fun aa() {}<!>
@@ -0,0 +1,14 @@
package
package foo {
public fun aa(): kotlin.Unit
public final class A {
@kotlin.js.JsName(name = "aa") public constructor A(/*0*/ x: kotlin.Int)
public constructor A(/*0*/ x: kotlin.String)
public final val x: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -319,6 +319,30 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("jsNameAndOverridden.kt")
public void testJsNameAndOverridden() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndOverridden.kt");
doTest(fileName);
}
@TestMetadata("jsNameAndPrivateDontClash.kt")
public void testJsNameAndPrivateDontClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameAndPrivateDontClash.kt");
doTest(fileName);
}
@TestMetadata("jsNameClash.kt")
public void testJsNameClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameClash.kt");
doTest(fileName);
}
@TestMetadata("jsNameClashWithDefault.kt")
public void testJsNameClashWithDefault() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/jsNameClashWithDefault.kt");
doTest(fileName);
}
@TestMetadata("methodAndMethod.kt")
public void testMethodAndMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndMethod.kt");
@@ -355,6 +379,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("privateJsNameClash.kt")
public void testPrivateJsNameClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/privateJsNameClash.kt");
doTest(fileName);
}
@TestMetadata("propertyAndMethodInSubclass.kt")
public void testPropertyAndMethodInSubclass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndMethodInSubclass.kt");
@@ -367,6 +397,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("topLevelMethodAndJsNameConstructor.kt")
public void testTopLevelMethodAndJsNameConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/topLevelMethodAndJsNameConstructor.kt");
doTest(fileName);
}
@TestMetadata("topLevelMethodAndProperty.kt")
public void testTopLevelMethodAndProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/topLevelMethodAndProperty.kt");