KT-2752: move tests, that check whether there's no name clash, to JS backend tests

This commit is contained in:
Alexey Andreev
2016-05-31 14:28:54 +03:00
parent 5ce158f297
commit 50dd1e31c3
26 changed files with 104 additions and 173 deletions
@@ -1,11 +0,0 @@
package foo
class A
class B
val A.foo: Int
get() = 32
val B.foo: Int
get() = 42
@@ -1,20 +0,0 @@
package
package foo {
public val foo.A.foo: kotlin.Int
public val foo.B.foo: kotlin.Int
public final class A {
public constructor A()
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
}
public final class B {
public constructor B()
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
}
}
@@ -1,8 +0,0 @@
package foo
class A
fun A.bar() = 32
val A.bar: Int
get() = 32
@@ -1,13 +0,0 @@
package
package foo {
public val foo.A.bar: kotlin.Int
public fun foo.A.bar(): kotlin.Int
public final class A {
public constructor A()
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
}
}
@@ -1,5 +0,0 @@
package foo
@JsName("bar") fun foo(x: Int) = x
private fun bar() = 42
@@ -1,6 +0,0 @@
package
package foo {
private fun bar(): kotlin.Int
@kotlin.js.JsName(name = "bar") public fun foo(/*0*/ x: kotlin.Int): kotlin.Int
}
@@ -1,5 +0,0 @@
package foo
fun bar() = 23
private val bar = 32
@@ -1,6 +0,0 @@
package
package foo {
private val bar: kotlin.Int = 32
public fun bar(): kotlin.Int
}
@@ -1,11 +0,0 @@
// FILE: foo.kt
package foo
fun bar(x: Int) = x
// FILE: foobar.kt
package foo.bar
val x = 42
@@ -1,9 +0,0 @@
package
package foo {
public fun bar(/*0*/ x: kotlin.Int): kotlin.Int
package foo.bar {
public val x: kotlin.Int = 42
}
}
@@ -1,13 +0,0 @@
// FILE: foo.kt
package foo
private fun bar() = 23
private val bar = 42
// FILE: foobar.kt
package foo.bar
val x = 42
@@ -1,10 +0,0 @@
package
package foo {
private val bar: kotlin.Int = 42
private fun bar(): kotlin.Int
package foo.bar {
public val x: kotlin.Int = 42
}
}
@@ -1,5 +0,0 @@
package foo
@native fun bar() = 23
val bar = 32
@@ -1,6 +0,0 @@
package
package foo {
public val bar: kotlin.Int = 32
@kotlin.js.native() public fun bar(): kotlin.Int
}
@@ -301,36 +301,18 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("extensionPropertiesWithDifferentReceiversDoNotClash.kt")
public void testExtensionPropertiesWithDifferentReceiversDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertiesWithDifferentReceiversDoNotClash.kt");
doTest(fileName);
}
@TestMetadata("extensionPropertyAndMethod.kt")
public void testExtensionPropertyAndMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethod.kt");
doTest(fileName);
}
@TestMetadata("extensionPropertyAndMethodDoNotClash.kt")
public void testExtensionPropertyAndMethodDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/extensionPropertyAndMethodDoNotClash.kt");
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");
@@ -349,30 +331,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("methodAndPrivatePropertyDoNotClash.kt")
public void testMethodAndPrivatePropertyDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/methodAndPrivatePropertyDoNotClash.kt");
doTest(fileName);
}
@TestMetadata("packageAndMangledMethodDoNotClash.kt")
public void testPackageAndMangledMethodDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMangledMethodDoNotClash.kt");
doTest(fileName);
}
@TestMetadata("packageAndMethod.kt")
public void testPackageAndMethod() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndMethod.kt");
doTest(fileName);
}
@TestMetadata("packageAndPrivateDeclarationsDoNotClash.kt")
public void testPackageAndPrivateDeclarationsDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndPrivateDeclarationsDoNotClash.kt");
doTest(fileName);
}
@TestMetadata("packageAndProperty.kt")
public void testPackageAndProperty() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/packageAndProperty.kt");
@@ -391,12 +355,6 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
doTest(fileName);
}
@TestMetadata("propertyAndNativeMethodDoNotClash.kt")
public void testPropertyAndNativeMethodDoNotClash() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/propertyAndNativeMethodDoNotClash.kt");
doTest(fileName);
}
@TestMetadata("topLevelMethodAndJsNameConstructor.kt")
public void testTopLevelMethodAndJsNameConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/name/topLevelMethodAndJsNameConstructor.kt");
@@ -23,8 +23,7 @@ enum class PredefinedAnnotation(fqName: String) {
NATIVE("kotlin.js.native"),
NATIVE_INVOKE("kotlin.js.nativeInvoke"),
NATIVE_GETTER("kotlin.js.nativeGetter"),
NATIVE_SETTER("kotlin.js.nativeSetter"),
JS_NAME("kotlin.js.JsName");
NATIVE_SETTER("kotlin.js.nativeSetter");
val fqName: FqName = FqName(fqName)
@@ -33,6 +33,7 @@ import java.util.List;
import java.util.Set;
public final class AnnotationsUtils {
private static final String JS_NAME = "kotlin.js.JsName";
private AnnotationsUtils() {
}
@@ -128,7 +129,7 @@ public final class AnnotationsUtils {
@Nullable
public static String getJsName(@NotNull DeclarationDescriptor descriptor) {
AnnotationDescriptor annotation = getAnnotationByName(descriptor, PredefinedAnnotation.JS_NAME.getFqName());
AnnotationDescriptor annotation = getAnnotationByName(descriptor, new FqName(JS_NAME));
if (annotation == null) return null;
ConstantValue<?> value = annotation.getAllValueArguments().values().iterator().next();
@@ -0,0 +1,9 @@
package foo
fun bar(x: Int) = x
fun box(): Boolean {
assertEquals(23, bar(23))
assertEquals(42, foo.bar.x)
return true
}
@@ -0,0 +1,3 @@
package foo.bar
val x = 42
@@ -0,0 +1,13 @@
package foo
private fun bar() = 23
private val bar = 42
fun box(): Boolean {
assertEquals(23, bar())
assertEquals(42, bar)
assertEquals(32, foo.bar.x)
return true
}
@@ -0,0 +1,3 @@
package foo.bar
val x = 32
@@ -0,0 +1,18 @@
package foo
class A
class B
val A.foo: Int
get() = 32
val B.foo: Int
get() = 42
fun box(): String {
assertEquals(32, A().foo)
assertEquals(42, B().foo)
return "OK"
}
@@ -0,0 +1,15 @@
package foo
class A
fun A.bar() = 23
val A.bar: Int
get() = 42
fun box(): String {
assertEquals(23, A().bar())
assertEquals(42, A().bar)
return "OK"
}
@@ -0,0 +1,12 @@
package foo
@JsName("bar") fun foo(x: Int) = x
private fun bar() = 42
fun box(): String {
assertEquals(23, foo(23))
assertEquals(42, bar())
return "OK"
}
@@ -0,0 +1,12 @@
package foo
fun bar() = 23
private val bar = 32
fun box(): String {
assertEquals(23, bar())
assertEquals(32, bar)
return "OK"
}
@@ -0,0 +1,16 @@
package foo
@native fun bar()
val bar = 32
fun createNativeBar() = js("bar = function() { return 23; };")
fun box(): String {
createNativeBar()
assertEquals(23, bar())
assertEquals(32, bar)
return "OK"
}