JS backend: introduce constants for default test package(foo) and default test function(box).
This commit is contained in:
@@ -49,6 +49,9 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
private static final String OUT = "out/";
|
private static final String OUT = "out/";
|
||||||
private static final String EXPECTED = "expected/";
|
private static final String EXPECTED = "expected/";
|
||||||
|
|
||||||
|
public static final String TEST_PACKAGE = "foo";
|
||||||
|
public static final String TEST_FUNCTION = "box";
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private String mainDirectory = "";
|
private String mainDirectory = "";
|
||||||
|
|
||||||
|
|||||||
@@ -47,15 +47,15 @@ public abstract class SingleFileTranslationTest extends BasicTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void checkFooBoxIsTrue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions) throws Exception {
|
public void checkFooBoxIsTrue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions) throws Exception {
|
||||||
runFunctionOutputTest(ecmaVersions, filename, "foo", "box", true);
|
runFunctionOutputTest(ecmaVersions, filename, TEST_PACKAGE, TEST_FUNCTION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFooBoxIsTrue(@NotNull String filename) throws Exception {
|
public void checkFooBoxIsTrue(@NotNull String filename) throws Exception {
|
||||||
runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, filename, "foo", "box", true);
|
runFunctionOutputTest(DEFAULT_ECMA_VERSIONS, filename, TEST_PACKAGE, TEST_FUNCTION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkFooBoxIsValue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions, Object expected) throws Exception {
|
public void checkFooBoxIsValue(@NotNull String filename, @NotNull Iterable<EcmaVersion> ecmaVersions, Object expected) throws Exception {
|
||||||
runFunctionOutputTest(ecmaVersions, filename, "foo", "box", expected);
|
runFunctionOutputTest(ecmaVersions, filename, TEST_PACKAGE, TEST_FUNCTION, expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fooBoxTest() throws Exception {
|
protected void fooBoxTest() throws Exception {
|
||||||
@@ -79,7 +79,7 @@ public abstract class SingleFileTranslationTest extends BasicTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void checkFooBoxIsOk(@NotNull Iterable<EcmaVersion> versions, @NotNull String filename) throws Exception {
|
protected void checkFooBoxIsOk(@NotNull Iterable<EcmaVersion> versions, @NotNull String filename) throws Exception {
|
||||||
runFunctionOutputTest(versions, filename, "foo", "box", "OK");
|
runFunctionOutputTest(versions, filename, TEST_PACKAGE, TEST_FUNCTION, "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkOutput(@NotNull String kotlinFilename,
|
protected void checkOutput(@NotNull String kotlinFilename,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public final class ClassInheritanceTest extends SingleFileTranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testInitializersOfBasicClassExecute() throws Exception {
|
public void testInitializersOfBasicClassExecute() throws Exception {
|
||||||
runFunctionOutputTest("initializersOfBasicClassExecute.kt", "foo", "box", 3);
|
fooBoxIsValue(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodOverride() throws Exception {
|
public void testMethodOverride() throws Exception {
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public final class ExamplesTest extends SingleFileTranslationTest {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runTest() throws Exception {
|
public void runTest() throws Exception {
|
||||||
runFunctionOutputTest(filename, Namer.getRootPackageName(), "box", "OK");
|
runFunctionOutputTest(filename, Namer.getRootPackageName(), TEST_FUNCTION, "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Test suite() throws Exception {
|
public static Test suite() throws Exception {
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ public class FunctionTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testClosureWithParameter() throws Exception {
|
public void testClosureWithParameter() throws Exception {
|
||||||
checkFooBoxIsOk("closureWithParameter.kt");
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClosureWithParameterAndBoxing() throws Exception {
|
public void testClosureWithParameterAndBoxing() throws Exception {
|
||||||
checkFooBoxIsOk("closureWithParameterAndBoxing.kt");
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnclosingThis() throws Exception {
|
public void testEnclosingThis() throws Exception {
|
||||||
runFunctionOutputTest("enclosingThis.kt", "foo", "box", "OK");
|
checkFooBoxIsOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,25 +24,22 @@ public final class PackageTest extends SingleFileTranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testNestedPackage() throws Exception {
|
public void testNestedPackage() throws Exception {
|
||||||
runFunctionOutputTest("nestedPackage.kt", "foo.bar", "box", true);
|
runFunctionOutputTest("nestedPackage.kt", "foo.bar", TEST_FUNCTION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeeplyNestedPackage() throws Exception {
|
public void testDeeplyNestedPackage() throws Exception {
|
||||||
runFunctionOutputTest("deeplyNestedPackage.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true);
|
runFunctionOutputTest("deeplyNestedPackage.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", TEST_FUNCTION, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDeeplyNestedPackageFunctionCalled() throws Exception {
|
public void testDeeplyNestedPackageFunctionCalled() throws Exception {
|
||||||
runFunctionOutputTest("deeplyNestedPackageFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true
|
runFunctionOutputTest("deeplyNestedPackageFunctionCalled.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", TEST_FUNCTION, true);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassCreatedInDeeplyNestedPackage() throws Exception {
|
public void testClassCreatedInDeeplyNestedPackage() throws Exception {
|
||||||
runFunctionOutputTest("classCreatedInDeeplyNestedPackage.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true
|
runFunctionOutputTest("classCreatedInDeeplyNestedPackage.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", TEST_FUNCTION, true);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitializersOfNestedPackagesExecute() throws Exception {
|
public void testInitializersOfNestedPackagesExecute() throws Exception {
|
||||||
runFunctionOutputTest("initializersOfNestedPackagesExecute.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", "box", true
|
runFunctionOutputTest("initializersOfNestedPackagesExecute.kt", "foo1.foo2.foo3.foo5.foo6.foo7.foo8", TEST_FUNCTION, true);
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public final class PatternMatchingTest extends SingleFileTranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testMultipleCases() throws Exception {
|
public void testMultipleCases() throws Exception {
|
||||||
runFunctionOutputTest("multipleCases.kt", "foo", "box", 2.0);
|
fooBoxIsValue(2.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMatchNullableType() throws Exception {
|
public void testMatchNullableType() throws Exception {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public final class PropertyAccessTest extends SingleFileTranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSetter() throws Exception {
|
public void testSetter() throws Exception {
|
||||||
runFunctionOutputTest("setter.kt", "foo", "f", 99.0);
|
fooBoxIsValue(99.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public final class StdLibTest extends SingleFileTranslationTest {
|
|||||||
|
|
||||||
generateJavaScriptFiles(files, kotlinFilename, mainCallParameters, ecmaVersions);
|
generateJavaScriptFiles(files, kotlinFilename, mainCallParameters, ecmaVersions);
|
||||||
runRhinoTests(kotlinFilename, ecmaVersions,
|
runRhinoTests(kotlinFilename, ecmaVersions,
|
||||||
new RhinoFunctionNativeObjectResultChecker("test.browser", "foo", "Some Dynamically Created Content!!!"));
|
new RhinoFunctionNativeObjectResultChecker("test.browser", TEST_FUNCTION, "Some Dynamically Created Content!!!"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class Test() {
|
|||||||
var a : Int = 1
|
var a : Int = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f() : Int {
|
fun box() : Int {
|
||||||
var a = Test()
|
var a = Test()
|
||||||
var b = Test()
|
var b = Test()
|
||||||
b.a = 100
|
b.a = 100
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package test.browser
|
|||||||
import js.dom.html.document
|
import js.dom.html.document
|
||||||
import org.w3c.dom.Node
|
import org.w3c.dom.Node
|
||||||
|
|
||||||
fun foo(): String {
|
fun box(): String {
|
||||||
val element = document.getElementById("foo")!!
|
val element = document.getElementById("foo")!!
|
||||||
val textNode = document.createTextNode("Some Dynamically Created Content!!!")
|
val textNode = document.createTextNode("Some Dynamically Created Content!!!")
|
||||||
element.appendChild(textNode)
|
element.appendChild(textNode)
|
||||||
|
|||||||
Reference in New Issue
Block a user