KT-2752: move tests, that check whether there's no name clash, to JS backend tests
This commit is contained in:
@@ -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();
|
||||
|
||||
+9
@@ -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
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo.bar
|
||||
|
||||
val x = 42
|
||||
+13
@@ -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
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package foo.bar
|
||||
|
||||
val x = 32
|
||||
+18
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user