migrated to junit3

This commit is contained in:
Pavel Talanov
2012-02-05 18:19:38 +04:00
parent 171c43cc6f
commit 1a01dfd848
42 changed files with 402 additions and 515 deletions
-1
View File
@@ -14,7 +14,6 @@
<element id="extracted-dir" path="$PROJECT_DIR$/translator/lib/guava-10.0.1.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/translator/lib/guava-10.0.1.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/../../Kotlin/jet/lib/asm-util-3.3.1.jar" path-in-jar="/" /> <element id="extracted-dir" path="$PROJECT_DIR$/../../Kotlin/jet/lib/asm-util-3.3.1.jar" path-in-jar="/" />
<element id="module-output" name="idea_fix" /> <element id="module-output" name="idea_fix" />
<element id="file-copy" path="E:/rt.jar" />
</root> </root>
</artifact> </artifact>
</component> </component>
+1 -1
View File
@@ -4,12 +4,12 @@
<modules> <modules>
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/backend/backend.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/backend/backend.iml" /> <module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/backend/backend.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/backend/backend.iml" />
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/cli/cli.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/cli/cli.iml" /> <module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/cli/cli.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/cli/cli.iml" />
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/tests/compiler-tests.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/tests/compiler-tests.iml" />
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/frontend.iml" /> <module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend/frontend.iml" />
<module fileurl="file://$PROJECT_DIR$/../Kotlin/jet/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/../Kotlin/jet/compiler/frontend/frontend.iml" /> <module fileurl="file://$PROJECT_DIR$/../Kotlin/jet/compiler/frontend/frontend.iml" filepath="$PROJECT_DIR$/../Kotlin/jet/compiler/frontend/frontend.iml" />
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend.java/frontend.java.iml" /> <module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/compiler/frontend.java/frontend.java.iml" />
<module fileurl="file://$PROJECT_DIR$/../Kotlin/jet/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/../Kotlin/jet/compiler/frontend.java/frontend.java.iml" /> <module fileurl="file://$PROJECT_DIR$/../Kotlin/jet/compiler/frontend.java/frontend.java.iml" filepath="$PROJECT_DIR$/../Kotlin/jet/compiler/frontend.java/frontend.java.iml" />
<module fileurl="file://$PROJECT_DIR$/idea_fix/idea_fix.iml" filepath="$PROJECT_DIR$/idea_fix/idea_fix.iml" /> <module fileurl="file://$PROJECT_DIR$/idea_fix/idea_fix.iml" filepath="$PROJECT_DIR$/idea_fix/idea_fix.iml" />
<module fileurl="file://$PROJECT_DIR$/examples/jetTests.iml" filepath="$PROJECT_DIR$/examples/jetTests.iml" />
<module fileurl="file://$PROJECT_DIR$/js/js.iml" filepath="$PROJECT_DIR$/js/js.iml" /> <module fileurl="file://$PROJECT_DIR$/js/js.iml" filepath="$PROJECT_DIR$/js/js.iml" />
<module fileurl="file://$PROJECT_DIR$/jslib/jslib.iml" filepath="$PROJECT_DIR$/jslib/jslib.iml" /> <module fileurl="file://$PROJECT_DIR$/jslib/jslib.iml" filepath="$PROJECT_DIR$/jslib/jslib.iml" />
<module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/stdlib/stdlib.iml" /> <module fileurl="file://$PROJECT_DIR$/../../Kotlin/jet/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/../../Kotlin/jet/stdlib/stdlib.iml" />
-34
View File
@@ -1,34 +0,0 @@
import com.intellij.testFramework.UsefulTestCase;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.k2js.test.ExampleTest;
public final class ExampleTestSuite extends UsefulTestCase {
private String name;
private ExampleTest tester = new ExampleTest();
public ExampleTestSuite(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
public void runTest() throws Exception {
tester.runBoxTest(getName());
}
public static Test suite() {
return JetTestCaseBuilder.suiteForDirectory("translator",
"/testFiles/examples/cases/", true, new JetTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public Test createTest(@NotNull String dataPath, @NotNull String name) {
return (new ExampleTestSuite(name));
}
});
}
}
+19
View File
@@ -147,6 +147,25 @@ public open class HashMap<erased K, erased V>() : java.util.Map<K, V> {
override public fun values() : java.util.Collection<V> {} override public fun values() : java.util.Collection<V> {}
} }
library
public open class LinkedList<erased E>() : List<E> {
override public fun iterator() : java.util.Iterator<E> {}
override public fun isEmpty() : Boolean {}
override public fun contains(o : Any?) : Boolean {}
override public fun size() : Int {}
override public fun add(e : E) : Boolean {}
override public fun remove(o : Any?) : Boolean {}
override public fun addAll(c : java.util.Collection<out E>) : Boolean {}
override public fun clear() : Unit {}
override public fun get(index : Int) : E {}
override public fun set(index : Int, element : E) : E {}
override public fun add(index : Int, element : E) : Unit {}
override public fun remove(index : Int) : E {}
public fun poll() : E? {}
public fun peek() : E? {}
public fun offer(e : E) : Boolean {}
}
library library
public class StringBuilder() { public class StringBuilder() {
public fun append(obj : Any) : StringBuilder public fun append(obj : Any) : StringBuilder
Binary file not shown.
@@ -2,7 +2,6 @@ package org.jetbrains.k2js.test;
import org.jetbrains.k2js.facade.K2JSTranslatorApplet; import org.jetbrains.k2js.facade.K2JSTranslatorApplet;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
@@ -18,14 +17,12 @@ public final class AppletTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testSimple() throws Exception {
public void simpleTest() throws Exception {
evaluateCodeWithParameters("fun main(args : Array<String>) {}", " a 3 1 2134", ""); evaluateCodeWithParameters("fun main(args : Array<String>) {}", " a 3 1 2134", "");
} }
@Test public void testSystemOutTest() throws Exception {
public void systemOutTest() throws Exception {
evaluateCodeWithParameters("class A() {} fun main(args : Array<String>) { var a = A();}", "", ""); evaluateCodeWithParameters("class A() {} fun main(args : Array<String>) { var a = A();}", "", "");
} }
@@ -1,6 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
import org.mozilla.javascript.JavaScriptException; import org.mozilla.javascript.JavaScriptException;
/** /**
@@ -15,38 +14,36 @@ public final class ArrayListTest extends JavaClassesTest {
return MAIN; return MAIN;
} }
@Test public void testEmptyList() throws Exception {
public void emptyList() throws Exception {
testFooBoxIsTrue("emptyList.kt"); testFooBoxIsTrue("emptyList.kt");
} }
@Test public void testAccess() throws Exception {
public void access() throws Exception {
testFooBoxIsTrue("access.kt"); testFooBoxIsTrue("access.kt");
} }
@Test public void testIsEmpty() throws Exception {
public void isEmpty() throws Exception {
testFooBoxIsTrue("isEmpty.kt"); testFooBoxIsTrue("isEmpty.kt");
} }
@Test public void testArrayAccess() throws Exception {
public void arrayAccess() throws Exception {
testFooBoxIsTrue("arrayAccess.kt"); testFooBoxIsTrue("arrayAccess.kt");
} }
@Test public void testIterate() throws Exception {
public void iterate() throws Exception {
testFooBoxIsTrue("iterate.kt"); testFooBoxIsTrue("iterate.kt");
} }
@Test public void testRemove() throws Exception {
public void remove() throws Exception {
testFooBoxIsTrue("remove.kt"); testFooBoxIsTrue("remove.kt");
} }
@Test(expected = JavaScriptException.class) public void testIndexOOB() throws Exception {
public void indexOOB() throws Exception { try {
testFooBoxIsTrue("indexOOB.kt"); testFooBoxIsTrue("indexOOB.kt");
fail();
} catch (JavaScriptException e) {
}
} }
} }
@@ -0,0 +1,35 @@
package org.jetbrains.k2js.test;
import com.intellij.openapi.project.Project;
import com.intellij.testFramework.UsefulTestCase;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.compiler.JetCoreEnvironment;
/**
* @author Pavel Talanov
*/
public abstract class BaseTest extends UsefulTestCase {
@NonNls
protected JetCoreEnvironment myEnvironment;
public Project getProject() {
return myEnvironment.getProject();
}
@Override
protected void setUp() throws Exception {
super.setUp();
// createEnvironmentWithMockJdk();
}
@Override
protected void tearDown() throws Exception {
myEnvironment = null;
super.tearDown();
}
protected void createEnvironmentWithMockJdk() {
myEnvironment = JetTestUtils.createEnvironmentWithMockJdk(getTestRootDisposable());
}
}
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,53 +12,44 @@ public class BasicClassTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void classInstantiation() throws Exception { public void testClassInstantiation() throws Exception {
testFooBoxIsTrue("classInstantiation.kt"); testFooBoxIsTrue("classInstantiation.kt");
} }
@Test public void testMethodDeclarationAndCall() throws Exception {
public void methodDeclarationAndCall() throws Exception {
testFooBoxIsTrue("methodDeclarationAndCall.kt"); testFooBoxIsTrue("methodDeclarationAndCall.kt");
} }
@Test public void testConstructorWithParameter() throws Exception {
public void constructorWithParameter() throws Exception {
testFooBoxIsTrue("constructorWithParameter.kt"); testFooBoxIsTrue("constructorWithParameter.kt");
} }
@Test public void testConstructorWithPropertiesAsParameters() throws Exception {
public void constructorWithPropertiesAsParameters() throws Exception {
testFooBoxIsTrue("constructorWithPropertiesAsParameters.kt"); testFooBoxIsTrue("constructorWithPropertiesAsParameters.kt");
} }
@Test public void testIncrementProperty() throws Exception {
public void incrementProperty() throws Exception {
testFunctionOutput("incrementProperty.kt", "foo", "box", "OK"); testFunctionOutput("incrementProperty.kt", "foo", "box", "OK");
} }
@Test public void testSimpleInitializer() throws Exception {
public void SimpleInitializer() throws Exception {
testFooBoxIsTrue("simpleInitializer.kt"); testFooBoxIsTrue("simpleInitializer.kt");
} }
@Test public void testComplexExpressionAsConstructorParameter() throws Exception {
public void complexExpressionAsConstructorParameter() throws Exception {
testFooBoxIsTrue("complexExpressionAsConstructorParameter.kt"); testFooBoxIsTrue("complexExpressionAsConstructorParameter.kt");
} }
@Test public void testPropertyAccess() throws Exception {
public void propertyAccess() throws Exception {
testFooBoxIsTrue("propertyAccess.kt"); testFooBoxIsTrue("propertyAccess.kt");
} }
@Test public void testPropertiesAsParametersInitialized() throws Exception {
public void propertiesAsParametersInitialized() throws Exception {
testFooBoxIsTrue("propertiesAsParametersInitialized.kt"); testFooBoxIsTrue("propertiesAsParametersInitialized.kt");
} }
@Test public void testClassWithoutNamespace() throws Exception {
public void classWithoutNamespace() throws Exception {
testFunctionOutput("classWithoutNamespace.kt", "Anonymous", "box", true); testFunctionOutput("classWithoutNamespace.kt", "Anonymous", "box", true);
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,38 +12,31 @@ public final class ClassInheritanceTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testInitializersOfBasicClassExecute() throws Exception {
public void initializersOfBasicClassExecute() throws Exception {
testFunctionOutput("initializersOfBasicClassExecute.kt", "foo", "box", 3); testFunctionOutput("initializersOfBasicClassExecute.kt", "foo", "box", 3);
} }
@Test public void testMethodOverride() throws Exception {
public void methodOverride() throws Exception {
testFooBoxIsTrue("methodOverride.kt"); testFooBoxIsTrue("methodOverride.kt");
} }
@Test public void testInitializationOrder() throws Exception {
public void initializationOrder() throws Exception {
testFooBoxIsTrue("initializationOrder.kt"); testFooBoxIsTrue("initializationOrder.kt");
} }
@Test public void testComplexInitializationOrder() throws Exception {
public void complexInitializationOrder() throws Exception {
testFooBoxIsTrue("complexInitializationOrder.kt"); testFooBoxIsTrue("complexInitializationOrder.kt");
} }
@Test public void testValuePassedToAncestorConstructor() throws Exception {
public void valuePassedToAncestorConstructor() throws Exception {
testFooBoxIsTrue("valuePassedToAncestorConstructor.kt"); testFooBoxIsTrue("valuePassedToAncestorConstructor.kt");
} }
@Test public void testBaseClassDefinedAfterDerived() throws Exception {
public void baseClassDefinedAfterDerived() throws Exception {
testFooBoxIsTrue("baseClassDefinedAfterDerived.kt"); testFooBoxIsTrue("baseClassDefinedAfterDerived.kt");
} }
@Test public void testDefinitionOrder() throws Exception {
public void definitionOrder() throws Exception {
testFooBoxIsTrue("definitionOrder.kt"); testFooBoxIsTrue("definitionOrder.kt");
} }
} }
@@ -1,6 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
import org.mozilla.javascript.JavaScriptException; import org.mozilla.javascript.JavaScriptException;
/** /**
@@ -15,23 +14,24 @@ public class ConditionalTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testIfElseAsExpression() throws Exception {
public void ifElseAsExpression() throws Exception {
testFooBoxIsTrue("ifElseAsExpression.kt"); testFooBoxIsTrue("ifElseAsExpression.kt");
} }
@Test public void testIfElse() throws Exception {
public void ifElse() throws Exception {
testFunctionOutput("if.kt", "foo", "box", 5); testFunctionOutput("if.kt", "foo", "box", 5);
} }
@Test public void testIfElseIf() throws Exception {
public void ifElseIf() throws Exception {
testFunctionOutput("elseif.kt", "foo", "box", 5); testFunctionOutput("elseif.kt", "foo", "box", 5);
} }
@Test(expected = JavaScriptException.class) public void testIfElseAsExpressionWithThrow() throws Exception {
public void ifElseAsExpressionWithThrow() throws Exception { try {
testFooBoxIsTrue("ifAsExpressionWithThrow.kt"); testFooBoxIsTrue("ifAsExpressionWithThrow.kt");
fail();
} catch (JavaScriptException e) {
}
} }
} }
@@ -1,18 +0,0 @@
package org.jetbrains.k2js.test;
/**
* @author Pavel Talanov
*/
public final class ExampleTest extends TranslationTest {
final private static String MAIN = "examples/";
@Override
protected String mainDirectory() {
return MAIN;
}
public void runBoxTest(String filename) throws Exception {
testFunctionOutput(filename, "Anonymous", "box", "OK");
}
}
@@ -0,0 +1,45 @@
package org.jetbrains.k2js.test;
import junit.framework.Test;
import org.jetbrains.annotations.NotNull;
public final class ExampleTestSuite extends TranslationTest {
final private static String MAIN = "examples/";
@Override
protected String mainDirectory() {
return MAIN;
}
public void runBoxTest(String filename) throws Exception {
testFunctionOutput(filename, "Anonymous", "box", "OK");
}
private String name;
public ExampleTestSuite(String name) {
this.name = name;
}
@Override
public String getName() {
return name;
}
public void runTest() throws Exception {
runBoxTest(getName());
}
public static Test suite() {
return TranslatorTestCaseBuilder.suiteForDirectory("translator",
"/testFiles/examples/cases/", true, new TranslatorTestCaseBuilder.NamedTestFactory() {
@NotNull
@Override
public Test createTest(@NotNull String dataPath, @NotNull String name) {
return (new ExampleTestSuite(name));
}
});
}
}
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -13,48 +11,39 @@ public final class ExtensionFunctionTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testIntExtension() throws Exception {
public void intExtension() throws Exception {
testFooBoxIsTrue("intExtension.kt"); testFooBoxIsTrue("intExtension.kt");
} }
@Test public void testExtensionWithImplicitReceiver() throws Exception {
public void extensionWithImplicitReceiver() throws Exception {
testFooBoxIsTrue("extensionWithImplicitReceiver.kt"); testFooBoxIsTrue("extensionWithImplicitReceiver.kt");
} }
@Test public void testExtensionFunctionOnExpression() throws Exception {
public void extensionFunctionOnExpression() throws Exception {
testFooBoxIsTrue("extensionFunctionOnExpression.kt"); testFooBoxIsTrue("extensionFunctionOnExpression.kt");
} }
@Test public void testExtensionUsedInsideClass() throws Exception {
public void extensionUsedInsideClass() throws Exception {
testFooBoxIsTrue("extensionUsedInsideClass.kt"); testFooBoxIsTrue("extensionUsedInsideClass.kt");
} }
@Test public void testVirtualExtension() throws Exception {
public void virtualExtension() throws Exception {
testFooBoxIsTrue("virtualExtension.kt"); testFooBoxIsTrue("virtualExtension.kt");
} }
@Test public void testVirtualExtensionOverride() throws Exception {
public void virtualExtensionOverride() throws Exception {
testFooBoxIsTrue("virtualExtensionOverride.kt"); testFooBoxIsTrue("virtualExtensionOverride.kt");
} }
@Test public void testExtensionLiteralPassedToFunction() throws Exception {
public void extensionLiteralPassedToFunction() throws Exception {
testFooBoxIsTrue("extensionLiteralPassedToFunction.kt"); testFooBoxIsTrue("extensionLiteralPassedToFunction.kt");
} }
@Test public void testExtensionInsideFunctionLiteral() throws Exception {
public void extensionInsideFunctionLiteral() throws Exception {
testFooBoxIsTrue("extensionInsideFunctionLiteral.kt"); testFooBoxIsTrue("extensionInsideFunctionLiteral.kt");
} }
@Test public void testGenericExtension() throws Exception {
public void genericExtension() throws Exception {
testFooBoxIsOk("generic.kt"); testFooBoxIsOk("generic.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -13,18 +11,15 @@ public final class ExtensionPropertyTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testSimplePropertyWithGetter() throws Exception {
public void simplePropertyWithGetter() throws Exception {
testFooBoxIsTrue("simplePropertyWithGetter.kt"); testFooBoxIsTrue("simplePropertyWithGetter.kt");
} }
@Test public void testPropertyWithGetterAndSetter() throws Exception {
public void propertyWithGetterAndSetter() throws Exception {
testFooBoxIsTrue("propertyWithGetterAndSetter.kt"); testFooBoxIsTrue("propertyWithGetterAndSetter.kt");
} }
@Test public void testAbsExtension() throws Exception {
public void absExtension() throws Exception {
testFooBoxIsTrue("absExtension.kt"); testFooBoxIsTrue("absExtension.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,13 +12,11 @@ public final class ForTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testForIteratesOverArray() throws Exception {
public void forIteratesOverArray() throws Exception {
testFooBoxIsTrue("forIteratesOverArray.kt"); testFooBoxIsTrue("forIteratesOverArray.kt");
} }
@Test public void testForOnEmptyArray() throws Exception {
public void forOnEmptyArray() throws Exception {
testFooBoxIsTrue("forOnEmptyArray.kt"); testFooBoxIsTrue("forOnEmptyArray.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,83 +12,74 @@ public class FunctionTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testFunctionUsedBeforeDeclaration() throws Exception {
public void functionUsedBeforeDeclaration() throws Exception {
testFooBoxIsTrue("functionUsedBeforeDeclaration.kt"); testFooBoxIsTrue("functionUsedBeforeDeclaration.kt");
} }
@Test public void testFunctionWithTwoParametersCall() throws Exception {
public void functionWithTwoParametersCall() throws Exception {
testFooBoxIsTrue("functionWithTwoParametersCall.kt"); testFooBoxIsTrue("functionWithTwoParametersCall.kt");
} }
@Test public void testFunctionLiteral() throws Exception {
public void functionLiteral() throws Exception {
testFooBoxIsTrue("functionLiteral.kt"); testFooBoxIsTrue("functionLiteral.kt");
} }
@Test public void testAdderClosure() throws Exception {
public void adderClosure() throws Exception {
testFooBoxIsTrue("adderClosure.kt"); testFooBoxIsTrue("adderClosure.kt");
} }
@Test public void testLoopClosure() throws Exception {
public void loopClosure() throws Exception {
testFooBoxIsTrue("loopClosure.kt"); testFooBoxIsTrue("loopClosure.kt");
} }
@Test public void testFunctionLiteralAsParameter() throws Exception {
public void functionLiteralAsParameter() throws Exception {
testFooBoxIsTrue("functionLiteralAsParameter.kt"); testFooBoxIsTrue("functionLiteralAsParameter.kt");
} }
@Test public void testClosureWithParameter() throws Exception {
public void closureWithParameter() throws Exception {
testFooBoxIsOk("closureWithParameter.kt"); testFooBoxIsOk("closureWithParameter.kt");
} }
@Test public void testClosureWithParameterAndBoxing() throws Exception {
public void closureWithParameterAndBoxing() throws Exception {
testFooBoxIsOk("closureWithParameterAndBoxing.jet"); testFooBoxIsOk("closureWithParameterAndBoxing.jet");
} }
@Test public void testEnclosingThis() throws Exception {
public void enclosingThis() throws Exception {
testFunctionOutput("enclosingThis.kt", "Anonymous", "box", "OK"); testFunctionOutput("enclosingThis.kt", "Anonymous", "box", "OK");
} }
@Test
public void implicitItParameter() throws Exception { public void testImplicitItParameter() throws Exception {
testFooBoxIsTrue("implicitItParameter.kt"); testFooBoxIsTrue("implicitItParameter.kt");
} }
@Test
public void defaultParameters() throws Exception { public void testDefaultParameters() throws Exception {
testFooBoxIsTrue("defaultParameters.kt"); testFooBoxIsTrue("defaultParameters.kt");
} }
@Test
public void functionLiteralAsLastParameter() throws Exception { public void testFunctionLiteralAsLastParameter() throws Exception {
testFooBoxIsTrue("functionLiteralAsLastParameter.kt"); testFooBoxIsTrue("functionLiteralAsLastParameter.kt");
} }
@Test
public void namedArguments() throws Exception { public void testNamedArguments() throws Exception {
testFooBoxIsTrue("namedArguments.kt"); testFooBoxIsTrue("namedArguments.kt");
} }
@Test
public void expressionAsFunction() throws Exception { public void testExpressionAsFunction() throws Exception {
testFooBoxIsTrue("expressionAsFunction.kt"); testFooBoxIsTrue("expressionAsFunction.kt");
} }
@Test
public void vararg() throws Exception { public void testVararg() throws Exception {
testFooBoxIsTrue("vararg.kt"); testFooBoxIsTrue("vararg.kt");
} }
@Test
public void kt921() throws Exception { public void testkt921() throws Exception {
try { try {
checkOutput("KT-921.kt", ""); checkOutput("KT-921.kt", "");
} catch (Throwable e) { } catch (Throwable e) {
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,13 +12,12 @@ public class IntrinsicTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testIntrinsicPlusAssign() throws Exception {
public void intrinsicPlusAssign() throws Exception {
testFooBoxIsTrue("plusAssign.kt"); testFooBoxIsTrue("plusAssign.kt");
} }
@Test
public void minusAssignOnProperty() throws Exception { public void testMinusAssignOnProperty() throws Exception {
testFooBoxIsTrue("minusAssignOnProperty.kt"); testFooBoxIsTrue("minusAssignOnProperty.kt");
} }
@@ -3,6 +3,7 @@ package org.jetbrains.k2js.test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@SuppressWarnings("FieldCanBeLocal")
public abstract class JavaClassesTest extends TranslationTest { public abstract class JavaClassesTest extends TranslationTest {
private final String SUITE = "java/"; private final String SUITE = "java/";
@@ -1,15 +0,0 @@
package org.jetbrains.k2js.test;
/**
* @author Pavel Talanov
*/
public final class JavascriptTest extends TranslationTest {
final private static String MAIN = "javascript/";
@Override
protected String mainDirectory() {
return MAIN;
}
}
@@ -1,6 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
import org.mozilla.javascript.Context; import org.mozilla.javascript.Context;
import org.mozilla.javascript.Scriptable; import org.mozilla.javascript.Scriptable;
@@ -11,7 +10,7 @@ import java.util.Map;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
public class KotlinLibTest extends TranslationTest { public final class KotlinLibTest extends TranslationTest {
final private static String MAIN = "kotlinLib/"; final private static String MAIN = "kotlinLib/";
@@ -25,8 +24,8 @@ public class KotlinLibTest extends TranslationTest {
runRhinoTest(Arrays.asList(kotlinLibraryPath()), new RhinoPropertyTypesChecker(objectName, propertyToType)); runRhinoTest(Arrays.asList(kotlinLibraryPath()), new RhinoPropertyTypesChecker(objectName, propertyToType));
} }
@Test
public void kotlinJsLibRunsWithRhino() throws Exception { public void testKotlinJsLibRunsWithRhino() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath()), new RhinoResultChecker() { runRhinoTest(Arrays.asList(kotlinLibraryPath()), new RhinoResultChecker() {
@Override @Override
public void runChecks(Context context, Scriptable scope) throws Exception { public void runChecks(Context context, Scriptable scope) throws Exception {
@@ -36,18 +35,15 @@ public class KotlinLibTest extends TranslationTest {
} }
//TODO: refactor //TODO: refactor
public void testCreatedTraitIsJSObject() throws Exception {
@Test
public void createdTraitIsJSObject() throws Exception {
final Map<String, Class<? extends Scriptable>> propertyToType final Map<String, Class<? extends Scriptable>> propertyToType
= new HashMap<String, Class<? extends Scriptable>>(); = new HashMap<String, Class<? extends Scriptable>>();
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("trait.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("trait.js")),
new RhinoPropertyTypesChecker("foo", propertyToType)); new RhinoPropertyTypesChecker("foo", propertyToType));
} }
@Test
public void createdNamespaceIsJSObject() throws Exception { public void testCreatedNamespaceIsJSObject() throws Exception {
final Map<String, Class<? extends Scriptable>> propertyToType final Map<String, Class<? extends Scriptable>> propertyToType
= new HashMap<String, Class<? extends Scriptable>>(); = new HashMap<String, Class<? extends Scriptable>>();
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespace.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespace.js")),
@@ -56,51 +52,49 @@ public class KotlinLibTest extends TranslationTest {
// //
// TODO:Refactor calls to function result checker with test // TODO:Refactor calls to function result checker with test
@Test public void testNamespaceHasDeclaredFunction() throws Exception {
public void namespaceHasDeclaredFunction() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespace.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespace.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test public void testNamespaceHasDeclaredClasses() throws Exception {
public void namespaceHasDeclaredClasses() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespaceWithClasses.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("namespaceWithClasses.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void isSameType() throws Exception { public void testIsSameType() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isSameType.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isSameType.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void isAncestorType() throws Exception { public void testIsAncestorType() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isAncestorType.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isAncestorType.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void isComplexTest() throws Exception { public void testIsComplexTest() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isComplexTest.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("isComplexTest.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void commaExpression() throws Exception { public void testCommaExpression() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("commaExpression.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("commaExpression.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void array() throws Exception { public void testArray() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("array.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("array.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@Test
public void hashMap() throws Exception { public void testHashMap() throws Exception {
runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("hashMap.js")), runRhinoTest(Arrays.asList(kotlinLibraryPath(), cases("hashMap.js")),
new RhinoFunctionResultChecker("test", true)); new RhinoFunctionResultChecker("test", true));
} }
@@ -1,14 +1,12 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
* <p/> * <p/>
* This class contains tests that do not fall in any particular category * This class contains tests that do not fall in any particular category
* most probably because that functionality has very little support * most probably because that functionality has very little support
*/ */
public class MiscTest extends AbstractExpressionTest { public final class MiscTest extends AbstractExpressionTest {
final private static String MAIN = "misc/"; final private static String MAIN = "misc/";
@Override @Override
@@ -16,25 +14,17 @@ public class MiscTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testNamespaceProperties() throws Exception {
public void namespaceProperties() throws Exception {
testFunctionOutput("localProperty.jet", "foo", "box", 50); testFunctionOutput("localProperty.jet", "foo", "box", 50);
} }
@Test public void testIntRange() throws Exception {
public void intRange() throws Exception {
// checkOutput("intRange.kt", " "); // checkOutput("intRange.kt", " ");
testFooBoxIsTrue("intRange.kt"); testFooBoxIsTrue("intRange.kt");
} }
@Test
public void safecallComputesExpressionOnlyOnce() throws Exception { public void testSafecallComputesExpressionOnlyOnce() throws Exception {
testFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt"); testFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt");
} }
//TODO:
// @Test
// public void jquery() throws Exception {
// testFooBoxIsTrue("jquery.kt");
// }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,13 +12,11 @@ public final class MultiFileTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testFunctionsVisibleFromOtherFile() throws Exception {
public void functionsVisibleFromOtherFile() throws Exception {
testFooBoxIsTrue("functionsVisibleFromOtherFile"); testFooBoxIsTrue("functionsVisibleFromOtherFile");
} }
@Test public void testClassesInheritedFromOtherFile() throws Exception {
public void classesInheritedFromOtherFile() throws Exception {
testFooBoxIsTrue("classesInheritedFromOtherFile"); testFooBoxIsTrue("classesInheritedFromOtherFile");
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,8 +12,7 @@ public final class NameClashesTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testMethodOverload() throws Exception {
public void methodOverload() throws Exception {
testFooBoxIsTrue("methodOverload.kt"); testFooBoxIsTrue("methodOverload.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,18 +12,18 @@ public final class ObjectTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void objectWithMethods() throws Exception { public void testObjectWithMethods() throws Exception {
testFooBoxIsTrue("objectWithMethods.kt"); testFooBoxIsTrue("objectWithMethods.kt");
} }
@Test
public void objectDeclaration() throws Exception { public void testObjectDeclaration() throws Exception {
testFooBoxIsTrue("objectDeclaration.kt"); testFooBoxIsTrue("objectDeclaration.kt");
} }
@Test
public void objectInMethod() throws Exception { public void testObjectInMethod() throws Exception {
testFooBoxIsTrue("objectInMethod.kt"); testFooBoxIsTrue("objectInMethod.kt");
} }
} }
@@ -1,11 +1,9 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
public class OperationTest extends AbstractExpressionTest { public final class OperationTest extends AbstractExpressionTest {
final private static String MAIN = "operation/"; final private static String MAIN = "operation/";
@Override @Override
@@ -13,33 +11,34 @@ public class OperationTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test
public void prefixIntOperations() throws Exception { public void testPrefixIntOperations() throws Exception {
testFooBoxIsTrue("prefixIntOperations.kt"); testFooBoxIsTrue("prefixIntOperations.kt");
} }
@Test
public void postfixIntOperations() throws Exception { public void testPostfixIntOperations() throws Exception {
testFooBoxIsTrue("postfixIntOperations.kt"); testFooBoxIsTrue("postfixIntOperations.kt");
} }
@Test
public void notBoolean() throws Exception { public void testNotBoolean() throws Exception {
testFooBoxIsTrue("notBoolean.kt"); testFooBoxIsTrue("notBoolean.kt");
} }
@Test
public void positiveAndNegativeNumbers() throws Exception { public void testPositiveAndNegativeNumbers() throws Exception {
testFooBoxIsTrue("positiveAndNegativeNumbers.kt"); testFooBoxIsTrue("positiveAndNegativeNumbers.kt");
} }
@Test
public void assign() throws Exception { public void testAssign() throws Exception {
testFunctionOutput("assign.kt", "foo", "f", 2.0); testFunctionOutput("assign.kt", "foo", "f", 2.0);
} }
@Test
public void comparison() throws Exception { public void testComparison() throws Exception {
testFooBoxIsTrue("comparison.kt"); testFooBoxIsTrue("comparison.kt");
} }
} }
@@ -1,11 +1,9 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
public class OperatorOverloadingTest extends TranslationTest { public final class OperatorOverloadingTest extends TranslationTest {
final private static String MAIN = "operatorOverloading/"; final private static String MAIN = "operatorOverloading/";
@@ -14,89 +12,87 @@ public class OperatorOverloadingTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void plusOverload() throws Exception { public void testPlusOverload() throws Exception {
testFooBoxIsTrue("plusOverload.kt"); testFooBoxIsTrue("plusOverload.kt");
} }
@Test
public void postfixInc() throws Exception { public void testPostfixInc() throws Exception {
testFooBoxIsTrue("postfixIncOverload.kt"); testFooBoxIsTrue("postfixIncOverload.kt");
} }
@Test
public void prefixInc() throws Exception { public void testPrefixInc() throws Exception {
testFooBoxIsTrue("prefixDecOverload.kt"); testFooBoxIsTrue("prefixDecOverload.kt");
} }
@Test
public void prefixIncReturnsCorrectValue() throws Exception { public void testPrefixIncReturnsCorrectValue() throws Exception {
testFooBoxIsTrue("prefixIncReturnsCorrectValue.kt"); testFooBoxIsTrue("prefixIncReturnsCorrectValue.kt");
} }
@Test
public void overloadedCallOnProperty() throws Exception { public void testOverloadedCallOnProperty() throws Exception {
testFooBoxIsTrue("overloadedCallOnProperty.kt"); testFooBoxIsTrue("overloadedCallOnProperty.kt");
} }
@Test
public void postfixOnProperty() throws Exception { public void testPostfixOnProperty() throws Exception {
testFooBoxIsTrue("postfixOnProperty.kt"); testFooBoxIsTrue("postfixOnProperty.kt");
} }
@Test
public void operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception { public void testOperatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception {
testFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt"); testFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt");
} }
@Test
public void unaryOnIntProperty() throws Exception { public void testUnaryOnIntProperty() throws Exception {
testFooBoxIsTrue("unaryOnIntProperty.kt"); testFooBoxIsTrue("unaryOnIntProperty.kt");
} }
@Test
public void unaryOnIntPropertyAsStatement() throws Exception { public void testUnaryOnIntPropertyAsStatement() throws Exception {
testFooBoxIsTrue("unaryOnIntProperty2.kt"); testFooBoxIsTrue("unaryOnIntProperty2.kt");
} }
@Test
public void binaryDivOverload() throws Exception { public void testBinaryDivOverload() throws Exception {
testFooBoxIsTrue("binaryDivOverload.kt"); testFooBoxIsTrue("binaryDivOverload.kt");
} }
@Test
public void plusAssignNoReassign() throws Exception { public void testPlusAssignNoReassign() throws Exception {
testFooBoxIsTrue("plusAssignNoReassign.kt"); testFooBoxIsTrue("plusAssignNoReassign.kt");
} }
@Test
public void plusAssignReassign() throws Exception { public void testPlusAssignReassign() throws Exception {
testFooBoxIsTrue("plusAssignReassign.kt"); testFooBoxIsTrue("plusAssignReassign.kt");
} }
@Test
public void notOverload() throws Exception { public void testNotOverload() throws Exception {
testFooBoxIsTrue("notOverload.kt"); testFooBoxIsTrue("notOverload.kt");
} }
@Test
public void compareTo() throws Exception { public void testCompareTo() throws Exception {
testFooBoxIsTrue("compareTo.kt"); testFooBoxIsTrue("compareTo.kt");
} }
@Test
public void plusAndMinusAsAnExpression() throws Exception { public void testPlusAndMinusAsAnExpression() throws Exception {
testFooBoxIsTrue("plusAndMinusAsAnExpression.kt"); testFooBoxIsTrue("plusAndMinusAsAnExpression.kt");
} }
@Test
public void usingModInCaseModAssignNotAvailable() throws Exception { public void testUsingModInCaseModAssignNotAvailable() throws Exception {
testFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt"); testFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt");
} }
public void testOverloadPlusAssignArrayList() throws Exception {
@Test
public void overloadPlusAssignArrayList() throws Exception {
testFooBoxIsOk("overloadPlusAssignArrayList.kt"); testFooBoxIsOk("overloadPlusAssignArrayList.kt");
} }
} }
@@ -1,6 +1,6 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test; import org.mozilla.javascript.JavaScriptException;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
@@ -14,58 +14,61 @@ public final class PatternMatchingTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void whenType() throws Exception { public void testWhenType() throws Exception {
testFooBoxIsTrue("whenType.kt"); testFooBoxIsTrue("whenType.kt");
} }
@Test
public void whenNotType() throws Exception { public void testWhenNotType() throws Exception {
testFooBoxIsTrue("whenNotType.kt"); testFooBoxIsTrue("whenNotType.kt");
} }
@Test
public void whenExecutesOnlyOnce() throws Exception { public void testWhenExecutesOnlyOnce() throws Exception {
testFooBoxIsTrue("whenExecutesOnlyOnce.kt"); testFooBoxIsTrue("whenExecutesOnlyOnce.kt");
} }
@Test
public void whenValue() throws Exception { public void testWhenValue() throws Exception {
testFooBoxIsTrue("whenValue.kt"); testFooBoxIsTrue("whenValue.kt");
} }
@Test
public void whenNotValue() throws Exception { public void testWhenNotValue() throws Exception {
testFooBoxIsTrue("whenNotValue.kt"); testFooBoxIsTrue("whenNotValue.kt");
} }
@Test
public void whenValueOrType() throws Exception { public void testWhenValueOrType() throws Exception {
testFooBoxIsTrue("whenValueOrType.kt"); testFooBoxIsTrue("whenValueOrType.kt");
} }
@Test
public void whenWithIf() throws Exception { public void testWhenWithIf() throws Exception {
testFooBoxIsTrue("whenWithIf.kt"); testFooBoxIsTrue("whenWithIf.kt");
} }
@Test
public void multipleCases() throws Exception { public void testMultipleCases() throws Exception {
testFunctionOutput("multipleCases.kt", "foo", "box", 2.0); testFunctionOutput("multipleCases.kt", "foo", "box", 2.0);
} }
@Test
public void matchNullableType() throws Exception { public void testMatchNullableType() throws Exception {
testFooBoxIsTrue("matchNullableType.kt"); testFooBoxIsTrue("matchNullableType.kt");
} }
@Test
public void whenAsExpression() throws Exception { public void testWhenAsExpression() throws Exception {
testFooBoxIsTrue("whenAsExpression.kt"); testFooBoxIsTrue("whenAsExpression.kt");
} }
@Test(expected = org.mozilla.javascript.JavaScriptException.class)
public void whenAsExpressionWithThrow() throws Exception { public void whenAsExpressionWithThrow() throws Exception {
testFooBoxIsTrue("whenAsExpressionWithThrow.kt"); try {
testFooBoxIsTrue("whenAsExpressionWithThrow.kt");
fail();
} catch (JavaScriptException e) {
}
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,59 +12,56 @@ public final class PropertyAccessTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void accessToInstanceProperty() throws Exception { public void testAccessToInstanceProperty() throws Exception {
testFooBoxIsTrue("accessToInstanceProperty.kt"); testFooBoxIsTrue("accessToInstanceProperty.kt");
} }
@Test
public void twoClassesWithProperties() throws Exception { public void testTwoClassesWithProperties() throws Exception {
testFooBoxIsTrue("twoClassesWithProperties.kt"); testFooBoxIsTrue("twoClassesWithProperties.kt");
} }
@Test
public void setter() throws Exception { public void testSetter() throws Exception {
testFunctionOutput("setter.kt", "foo", "f", 99.0); testFunctionOutput("setter.kt", "foo", "f", 99.0);
} }
@Test
public void customGetter() throws Exception { public void testCustomGetter() throws Exception {
testFooBoxIsTrue("customGetter.kt"); testFooBoxIsTrue("customGetter.kt");
} }
@Test
public void customSetter() throws Exception { public void testCustomSetter() throws Exception {
testFooBoxIsTrue("customSetter.kt"); testFooBoxIsTrue("customSetter.kt");
} }
@Test
public void safeCall() throws Exception { public void testSafeCall() throws Exception {
testFooBoxIsTrue("safeCall.kt"); testFooBoxIsTrue("safeCall.kt");
} }
@Test
public void safeCallReturnsNullIfFails() throws Exception { public void testSafeCallReturnsNullIfFails() throws Exception {
testFooBoxIsTrue("safeCallReturnsNullIfFails.kt"); testFooBoxIsTrue("safeCallReturnsNullIfFails.kt");
} }
@Test
public void namespacePropertyInitializer() throws Exception { public void testNamespacePropertyInitializer() throws Exception {
testFooBoxIsTrue("namespacePropertyInitializer.kt"); testFooBoxIsTrue("namespacePropertyInitializer.kt");
} }
@Test
public void namespacePropertySet() throws Exception { public void testNamespacePropertySet() throws Exception {
testFooBoxIsTrue("namespacePropertySet.kt"); testFooBoxIsTrue("namespacePropertySet.kt");
} }
//TODO test public void testNamespaceCustomAccessors() throws Exception {
@Test
public void namespaceCustomAccessors() throws Exception {
testFooBoxIsTrue("namespaceCustomAccessors.kt"); testFooBoxIsTrue("namespaceCustomAccessors.kt");
} }
@Test
public void classUsesNamespaceProperties() throws Exception { public void classUsesNamespaceProperties() throws Exception {
testFooBoxIsTrue("classUsesNamespaceProperties.kt"); testFooBoxIsTrue("classUsesNamespaceProperties.kt");
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,13 +12,11 @@ public class RTTITest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testIsSameClass() throws Exception {
public void isSameClass() throws Exception {
testFooBoxIsTrue("isSameClass.kt"); testFooBoxIsTrue("isSameClass.kt");
} }
@Test public void testNotIsOtherClass() throws Exception {
public void notIsOtherClass() throws Exception {
testFooBoxIsTrue("notIsOtherClass.kt"); testFooBoxIsTrue("notIsOtherClass.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,20 +12,19 @@ public final class RangeTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void explicitRange() throws Exception { public void testExplicitRange() throws Exception {
testFooBoxIsTrue("explicitRange.kt"); testFooBoxIsTrue("explicitRange.kt");
} }
@Test
public void rangeSugarSyntax() throws Exception { public void testRangeSugarSyntax() throws Exception {
testFooBoxIsTrue("rangeSugarSyntax.kt"); testFooBoxIsTrue("rangeSugarSyntax.kt");
} }
@Test
public void intInRange() throws Exception { public void testIntInRange() throws Exception {
testFooBoxIsTrue("intInRange.kt"); testFooBoxIsTrue("intInRange.kt");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -13,40 +11,40 @@ public class StandardClassesTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void array() throws Exception { public void testArray() throws Exception {
testFooBoxIsTrue("array.kt"); testFooBoxIsTrue("array.kt");
} }
@Test
public void arrayAccess() throws Exception { public void testArrayAccess() throws Exception {
testFooBoxIsTrue("arrayAccess.kt"); testFooBoxIsTrue("arrayAccess.kt");
} }
@Test
public void arrayIsFilledWithNulls() throws Exception { public void testArrayIsFilledWithNulls() throws Exception {
testFooBoxIsTrue("arrayIsFilledWithNulls.kt"); testFooBoxIsTrue("arrayIsFilledWithNulls.kt");
} }
@Test
public void arrayFunctionConstructor() throws Exception { public void testArrayFunctionConstructor() throws Exception {
testFooBoxIsTrue("arrayFunctionConstructor.kt"); testFooBoxIsTrue("arrayFunctionConstructor.kt");
} }
@Test
public void arraySize() throws Exception { public void testArraySize() throws Exception {
testFooBoxIsTrue("arraySize.kt"); testFooBoxIsTrue("arraySize.kt");
} }
//TODO: this feature in not supported for some time //TODO: this feature in not supported for some time
//TODO: support it. Probably confugurable. //TODO: support it. Probably configurable.
// @Test(expected = JavaScriptException.class) // (expected = JavaScriptException.class)
// public void arrayThrowsExceptionOnOOBaccess() throws Exception { // public void arrayThrowsExceptionOnOOBaccess() throws Exception {
// testFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt"); // testFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt");
// } // }
@Test
public void arraysIterator() throws Exception { public void testArraysIterator() throws Exception {
testFooBoxIsTrue("arraysIterator.kt"); testFooBoxIsTrue("arraysIterator.kt");
} }
} }
@@ -1,19 +0,0 @@
package org.jetbrains.k2js.test;
/**
* @author Pavel Talanov
*/
public final class StdlibTest extends TranslationTest {
final private static String MAIN = "stdlib/";
@Override
protected String mainDirectory() {
return MAIN;
}
//TODO: cant do due to big java dependencies
// @Test
// public void filter() throws Exception {
// testFooBoxIsTrue("Filter.kt");
// }
}
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,28 +12,28 @@ public class StringTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test
public void stringConstant() throws Exception { public void testStringConstant() throws Exception {
testFooBoxIsTrue("stringConstant.kt"); testFooBoxIsTrue("stringConstant.kt");
} }
@Test
public void stringAssignment() throws Exception { public void testStringAssignment() throws Exception {
testFooBoxIsTrue("stringAssignment.kt"); testFooBoxIsTrue("stringAssignment.kt");
} }
@Test
public void intInTemplate() throws Exception { public void testIntInTemplate() throws Exception {
testFunctionOutput("intInTemplate.kt", "foo", "box", "my age is 3"); testFunctionOutput("intInTemplate.kt", "foo", "box", "my age is 3");
} }
@Test
public void stringInTemplate() throws Exception { public void testStringInTemplate() throws Exception {
testFunctionOutput("stringInTemplate.kt", "foo", "box", "oHelloo"); testFunctionOutput("stringInTemplate.kt", "foo", "box", "oHelloo");
} }
@Test
public void multipleExpressionInTemplate() throws Exception { public void testMultipleExpressionInTemplate() throws Exception {
testFunctionOutput("multipleExpressionsInTemplate.kt", "foo", "box", "left = 3\nright = 2\nsum = 5\n"); testFunctionOutput("multipleExpressionsInTemplate.kt", "foo", "box", "left = 3\nright = 2\nsum = 5\n");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,45 +12,43 @@ public final class TraitTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void traitAddsFunctionsToClass() throws Exception { public void testTraitAddsFunctionsToClass() throws Exception {
testFooBoxIsTrue("traitAddsFunctionsToClass.kt"); testFooBoxIsTrue("traitAddsFunctionsToClass.kt");
} }
@Test
public void classDerivesFromClassAndTrait() throws Exception { public void testClassDerivesFromClassAndTrait() throws Exception {
testFooBoxIsTrue("classDerivesFromClassAndTrait.kt"); testFooBoxIsTrue("classDerivesFromClassAndTrait.kt");
} }
@Test
public void classDerivesFromTraitAndClass() throws Exception { public void testClassDerivesFromTraitAndClass() throws Exception {
testFooBoxIsTrue("classDerivesFromTraitAndClass.kt"); testFooBoxIsTrue("classDerivesFromTraitAndClass.kt");
} }
@Test
public void example() throws Exception { public void testExample() throws Exception {
testFooBoxIsTrue("example.kt"); testFooBoxIsTrue("example.kt");
} }
@Test
public void traitExtendsTrait() throws Exception { public void testTraitExtendsTrait() throws Exception {
testFooBoxIsTrue("traitExtendsTrait.kt"); testFooBoxIsTrue("traitExtendsTrait.kt");
} }
@Test
public void traitExtendsTwoTraits() throws Exception { public void testTraitExtendsTwoTraits() throws Exception {
testFooBoxIsTrue("traitExtendsTwoTraits.kt"); testFooBoxIsTrue("traitExtendsTwoTraits.kt");
} }
@Test
public void funDelegation() throws Exception { public void testFunDelegation() throws Exception {
testFooBoxIsOk("funDelegation.jet"); testFooBoxIsOk("funDelegation.jet");
} }
@Test
public void definitionOrder() throws Exception { public void testDefinitionOrder() throws Exception {
testFooBoxIsTrue("definitionOrder.kt"); testFooBoxIsTrue("definitionOrder.kt");
} }
} }
@@ -20,7 +20,7 @@ import java.util.List;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
public abstract class TranslationTest { public abstract class TranslationTest extends BaseTest {
private final static String TEST_FILES = "translator/testFiles/"; private final static String TEST_FILES = "translator/testFiles/";
private static final String CASES = "cases/"; private static final String CASES = "cases/";
@@ -1,3 +1,5 @@
package org.jetbrains.k2js.test;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -10,9 +12,9 @@ import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
* @author abreslav * @author PavelTalanov
*/ */
public abstract class JetTestCaseBuilder { public abstract class TranslatorTestCaseBuilder {
public static FilenameFilter emptyFilter = new FilenameFilter() { public static FilenameFilter emptyFilter = new FilenameFilter() {
@Override @Override
public boolean accept(File file, String name) { public boolean accept(File file, String name) {
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,13 +12,11 @@ public final class TupleTest extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testTwoElements() throws Exception {
public void twoElements() throws Exception {
testFooBoxIsTrue("twoElements.kt"); testFooBoxIsTrue("twoElements.kt");
} }
@Test public void testMultipleMembers() throws Exception {
public void multipleMembers() throws Exception {
testFooBoxIsTrue("multipleMembers.kt"); testFooBoxIsTrue("multipleMembers.kt");
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,39 +12,39 @@ public final class WebDemoExamples1Test extends TranslationTest {
return MAIN; return MAIN;
} }
@Test
public void printArg() throws Exception { public void testPrintArg() throws Exception {
checkOutput("printArg.kt", "Hello, world!", "Hello, world!"); checkOutput("printArg.kt", "Hello, world!", "Hello, world!");
} }
@Test
public void whileLoop() throws Exception { public void testWhileLoop() throws Exception {
checkOutput("whileLoop.kt", "guest1\nguest2\nguest3\nguest4\n", "guest1", "guest2", "guest3", "guest4"); checkOutput("whileLoop.kt", "guest1\nguest2\nguest3\nguest4\n", "guest1", "guest2", "guest3", "guest4");
} }
@Test
public void ifAsExpression() throws Exception { public void testIfAsExpression() throws Exception {
checkOutput("ifAsExpression.kt", "20\n", "10", "20"); checkOutput("ifAsExpression.kt", "20\n", "10", "20");
} }
@Test
public void objectOrientedHello() throws Exception { public void testObjectOrientedHello() throws Exception {
checkOutput("objectOrientedHello.kt", "Hello, Pavel!\n", "Pavel"); checkOutput("objectOrientedHello.kt", "Hello, Pavel!\n", "Pavel");
} }
@Test
public void multiLanguageHello() throws Exception { public void testMultiLanguageHello() throws Exception {
checkOutput("multiLanguageHello.kt", "Salut!\n", "FR"); checkOutput("multiLanguageHello.kt", "Salut!\n", "FR");
} }
@Test
public void nullChecks() throws Exception { public void testNullChecks() throws Exception {
checkOutput("nullChecks.kt", "No number supplied"); checkOutput("nullChecks.kt", "No number supplied");
checkOutput("nullChecks.kt", "6", "2", "3"); checkOutput("nullChecks.kt", "6", "2", "3");
} }
@Test
public void ranges() throws Exception { public void testRanges() throws Exception {
checkOutput("ranges.kt", "OK\n" + checkOutput("ranges.kt", "OK\n" +
" 1 2 3 4 5\n" + " 1 2 3 4 5\n" +
"Out: array has only 3 elements. x = 4\n" + "Out: array has only 3 elements. x = 4\n" +
@@ -59,8 +57,8 @@ public final class WebDemoExamples1Test extends TranslationTest {
"No: array doesn't contains ddd\n", "10"); "No: array doesn't contains ddd\n", "10");
} }
@Test
public void forLoop() throws Exception { public void testForLoop() throws Exception {
checkOutput("forLoop.kt", "a\n" + checkOutput("forLoop.kt", "a\n" +
"b\n" + "b\n" +
"c\n" + "c\n" +
@@ -71,18 +69,16 @@ public final class WebDemoExamples1Test extends TranslationTest {
checkOutput("forLoop.kt", "123\n\n123\n", "123"); checkOutput("forLoop.kt", "123\n\n123\n", "123");
} }
@Test
public void isCheck() throws Exception { public void testIsCheck() throws Exception {
checkOutput("isCheck.kt", "3\nnull\n"); checkOutput("isCheck.kt", "3\nnull\n");
} }
@Test
public void patternMatching() throws Exception { public void testPatternMatching() throws Exception {
checkOutput("patternMatching.kt", "Greeting\n" + checkOutput("patternMatching.kt", "Greeting\n" +
"One\n" + "One\n" +
"Not a string\n" + "Not a string\n" +
"Unknown\n"); "Unknown\n");
} }
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -14,20 +12,16 @@ public final class WebDemoExamples2Test extends TranslationTest {
return MAIN; return MAIN;
} }
@Test public void testBottles() throws Exception {
public void bottles() throws Exception {
testWithMain("bottles", "2", "2"); testWithMain("bottles", "2", "2");
testWithMain("bottles", ""); testWithMain("bottles", "");
} }
//TODO: a couple of classes not supported and objects public void testLife() throws Exception {
@Test
public void life() throws Exception {
testWithMain("life", "", "2"); testWithMain("life", "", "2");
} }
@Test public void testBuilder() throws Exception {
public void builder() throws Exception {
testWithMain("builder", ""); testWithMain("builder", "");
testWithMain("builder", "1", "over9000"); testWithMain("builder", "1", "over9000");
} }
@@ -1,7 +1,5 @@
package org.jetbrains.k2js.test; package org.jetbrains.k2js.test;
import org.junit.Test;
/** /**
* @author Pavel Talanov * @author Pavel Talanov
*/ */
@@ -13,43 +11,38 @@ public final class WhileTest extends AbstractExpressionTest {
return MAIN; return MAIN;
} }
@Test public void testWhileSimpleTest() throws Exception {
public void whileSimpleTest() throws Exception {
testFooBoxIsTrue("while.kt"); testFooBoxIsTrue("while.kt");
} }
@Test public void testDoWhileSimpleTest() throws Exception {
public void doWhileSimpleTest() throws Exception {
testFooBoxIsTrue("doWhile.kt"); testFooBoxIsTrue("doWhile.kt");
} }
@Test public void testDoWhileExecutesAtLeastOnce() throws Exception {
public void doWhileExecutesAtLeastOnce() throws Exception {
testFooBoxIsTrue("doWhile2.kt"); testFooBoxIsTrue("doWhile2.kt");
} }
@Test public void testWhileDoesntExecuteEvenOnceIfConditionIsFalse() throws Exception {
public void whileDoesntExecuteEvenOnceIfConditionIsFalse() throws Exception {
testFooBoxIsTrue("while2.kt"); testFooBoxIsTrue("while2.kt");
} }
@Test public void testBreakWhile() throws Exception {
public void breakWhile() throws Exception {
testFooBoxIsTrue("breakWhile.kt"); testFooBoxIsTrue("breakWhile.kt");
} }
@Test
public void breakDoWhile() throws Exception { public void testBreakDoWhile() throws Exception {
testFooBoxIsTrue("breakDoWhile.kt"); testFooBoxIsTrue("breakDoWhile.kt");
} }
@Test
public void continueWhile() throws Exception { public void testContinueWhile() throws Exception {
testFooBoxIsTrue("continueWhile.kt"); testFooBoxIsTrue("continueWhile.kt");
} }
@Test
public void continueDoWhile() throws Exception { public void testContinueDoWhile() throws Exception {
testFooBoxIsTrue("continueDoWhile.kt"); testFooBoxIsTrue("continueDoWhile.kt");
} }
} }
+1 -1
View File
@@ -23,10 +23,10 @@
</library> </library>
</orderEntry> </orderEntry>
<orderEntry type="library" name="guava-10.0.1" level="application" /> <orderEntry type="library" name="guava-10.0.1" level="application" />
<orderEntry type="library" name="junit-4.10" level="application" />
<orderEntry type="library" name="js" level="application" /> <orderEntry type="library" name="js" level="application" />
<orderEntry type="library" name="idea-full" level="application" /> <orderEntry type="library" name="idea-full" level="application" />
<orderEntry type="module" module-name="js" /> <orderEntry type="module" module-name="js" />
<orderEntry type="module" module-name="compiler-tests" />
</component> </component>
</module> </module>