From 0710efdc16b9073028bcf77e7d0dd088cef40bd2 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Tue, 31 Jul 2012 18:38:26 +0400 Subject: [PATCH] Add tests for newly discovered issue with ECMA5 and top level vars in root scope. --- .../jetbrains/k2js/test/semantics/MiscTest.java | 10 ++++++++++ .../misc/cases/namespaceLevelVarInPackage.kt | 14 ++++++++++++++ .../misc/cases/namespaceLevelVarInRoot.kt | 12 ++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInPackage.kt create mode 100644 js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInRoot.kt diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java index 326366e3601..8dd344d1a48 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/MiscTest.java @@ -152,6 +152,16 @@ public final class MiscTest extends AbstractExpressionTest { fooBoxTest(); } + public void testNamespaceLevelVarInPackage() throws Exception { + fooBoxIsValue("OK"); + } + + //TODO: see http://youtrack.jetbrains.com/issue/KT-2564 + @SuppressWarnings("UnusedDeclaration") + public void TODO_testNamespaceLevelVarInRoot() throws Exception { + runFunctionOutputTest("namespaceLevelVarInRoot.kt", Namer.getRootNamespaceName(), "box", "OK"); + } + public void testLazyPropertyGetterNotCalledOnStart() throws Exception { checkOutput("lazyProperty.kt", "Hello, world! Gotcha 3"); } diff --git a/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInPackage.kt b/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInPackage.kt new file mode 100644 index 00000000000..4732cce011d --- /dev/null +++ b/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInPackage.kt @@ -0,0 +1,14 @@ +package foo + +var c = 2 + +fun incC(i: Int) { + c += c + i +} + +fun box() : Any? { + for (i in 0..2) { + incC(i) + } + return if (c == 20) "OK" else c +} \ No newline at end of file diff --git a/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInRoot.kt b/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInRoot.kt new file mode 100644 index 00000000000..b482152fdb2 --- /dev/null +++ b/js/js.translator/testFiles/expression/misc/cases/namespaceLevelVarInRoot.kt @@ -0,0 +1,12 @@ +var c = 2 + +fun incC(i: Int) { + c += c + i +} + +fun box() : Any? { + for (i in 0..2) { + incC(i) + } + return if (c == 20) "OK" else c +} \ No newline at end of file