[KT-4124] Add test case for nested native class
This commit is contained in:
@@ -16,8 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.js.test.semantics;
|
package org.jetbrains.kotlin.js.test.semantics;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.js.JavaScript;
|
||||||
|
import org.jetbrains.kotlin.js.config.EcmaVersion;
|
||||||
import org.jetbrains.kotlin.js.test.SingleFileTranslationTest;
|
import org.jetbrains.kotlin.js.test.SingleFileTranslationTest;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class NestedTypesTest extends SingleFileTranslationTest {
|
public class NestedTypesTest extends SingleFileTranslationTest {
|
||||||
public NestedTypesTest() {
|
public NestedTypesTest() {
|
||||||
super("nestedTypes/");
|
super("nestedTypes/");
|
||||||
@@ -42,4 +49,22 @@ public class NestedTypesTest extends SingleFileTranslationTest {
|
|||||||
public void testOuterObject() throws Exception {
|
public void testOuterObject() throws Exception {
|
||||||
checkFooBoxIsOk();
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testNestedNative() throws Exception {
|
||||||
|
checkFooBoxIsOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected List<String> additionalJsFiles(@NotNull EcmaVersion ecmaVersion) {
|
||||||
|
List<String> result = Lists.newArrayList(super.additionalJsFiles(ecmaVersion));
|
||||||
|
|
||||||
|
String jsFilePath = pathToTestDir() + "native/" + getTestName(true) + JavaScript.DOT_EXTENSION;
|
||||||
|
File jsFile = new File(jsFilePath);
|
||||||
|
if (jsFile.exists() && jsFile.isFile()) {
|
||||||
|
result.add(jsFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
open class A {
|
||||||
|
@native class B(value: Int = 0) {
|
||||||
|
val foo: Int
|
||||||
|
get() = noImpl
|
||||||
|
fun bar(): Int = noImpl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
var b = A.B(23)
|
||||||
|
if (b.foo != 123) return "failed1: ${b.foo}"
|
||||||
|
if (b.bar() != 1123) return "failed2: ${b.bar()}"
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
function B(value) {
|
||||||
|
this.foo = 100 + value;
|
||||||
|
}
|
||||||
|
B.prototype = {};
|
||||||
|
B.prototype.bar = function() {
|
||||||
|
return this.foo + 1000;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user