From fe9bb67970c3a0413909e509c6dc464d4bbbbc77 Mon Sep 17 00:00:00 2001 From: pTalanov Date: Tue, 28 Feb 2012 16:53:28 +0400 Subject: [PATCH] Refactor js.tests. --- js/js.tests/js.tests.iml | 2 +- .../jetbrains/k2js/test/ArrayListTest.java | 14 ++++---- .../k2js/test/ClassInheritanceTest.java | 12 +++---- .../jetbrains/k2js/test/ConditionalTest.java | 2 +- .../k2js/test/ExtensionFunctionTest.java | 18 +++++------ .../k2js/test/ExtensionPropertyTest.java | 6 ++-- .../test/org/jetbrains/k2js/test/ForTest.java | 4 +-- .../org/jetbrains/k2js/test/FunctionTest.java | 30 ++++++++--------- .../org/jetbrains/k2js/test/MiscTest.java | 4 +-- .../jetbrains/k2js/test/MultiFileTest.java | 6 ++-- .../k2js/test/MultiNamespaceTest.java | 6 ++-- .../jetbrains/k2js/test/NameClashesTest.java | 2 +- .../org/jetbrains/k2js/test/ObjectTest.java | 6 ++-- .../k2js/test/OperatorOverloadingTest.java | 32 +++++++++---------- .../k2js/test/PatternMatchingTest.java | 20 ++++++------ .../k2js/test/PropertyAccessTest.java | 26 +++++++-------- .../org/jetbrains/k2js/test/RTTITest.java | 4 +-- .../org/jetbrains/k2js/test/RangeTest.java | 8 ++--- .../jetbrains/k2js/test/SimpleTestSuite.java | 2 +- .../k2js/test/StandardClassesTest.java | 14 ++++---- .../org/jetbrains/k2js/test/StringTest.java | 6 ++-- .../org/jetbrains/k2js/test/TraitTest.java | 16 +++++----- .../jetbrains/k2js/test/TranslationTest.java | 29 ++++++++--------- .../org/jetbrains/k2js/test/TupleTest.java | 4 +-- .../k2js/test/WebDemoExamples2Test.java | 12 +++---- .../jetbrains/k2js/facade/K2JSTranslator.java | 13 ++++++-- 26 files changed, 151 insertions(+), 147 deletions(-) diff --git a/js/js.tests/js.tests.iml b/js/js.tests/js.tests.iml index 72acf26a5cc..aa9f0a6aab3 100644 --- a/js/js.tests/js.tests.iml +++ b/js/js.tests/js.tests.iml @@ -5,7 +5,7 @@ - + diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ArrayListTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ArrayListTest.java index 7e3f7506cab..85d4a4706cc 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ArrayListTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ArrayListTest.java @@ -31,32 +31,32 @@ public final class ArrayListTest extends JavaClassesTest { } public void testEmptyList() throws Exception { - testFooBoxIsTrue("emptyList.kt"); + checkFooBoxIsTrue("emptyList.kt"); } public void testAccess() throws Exception { - testFooBoxIsTrue("access.kt"); + checkFooBoxIsTrue("access.kt"); } public void testIsEmpty() throws Exception { - testFooBoxIsTrue("isEmpty.kt"); + checkFooBoxIsTrue("isEmpty.kt"); } public void testArrayAccess() throws Exception { - testFooBoxIsTrue("arrayAccess.kt"); + checkFooBoxIsTrue("arrayAccess.kt"); } public void testIterate() throws Exception { - testFooBoxIsTrue("iterate.kt"); + checkFooBoxIsTrue("iterate.kt"); } public void testRemove() throws Exception { - testFooBoxIsTrue("remove.kt"); + checkFooBoxIsTrue("remove.kt"); } public void testIndexOOB() throws Exception { try { - testFooBoxIsTrue("indexOOB.kt"); + checkFooBoxIsTrue("indexOOB.kt"); fail(); } catch (JavaScriptException e) { diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ClassInheritanceTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ClassInheritanceTest.java index ed2d3369c68..6aa1d44b8cc 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ClassInheritanceTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ClassInheritanceTest.java @@ -33,27 +33,27 @@ public final class ClassInheritanceTest extends TranslationTest { } public void testMethodOverride() throws Exception { - testFooBoxIsTrue("methodOverride.kt"); + checkFooBoxIsTrue("methodOverride.kt"); } public void testInitializationOrder() throws Exception { - testFooBoxIsTrue("initializationOrder.kt"); + checkFooBoxIsTrue("initializationOrder.kt"); } public void testComplexInitializationOrder() throws Exception { - testFooBoxIsTrue("complexInitializationOrder.kt"); + checkFooBoxIsTrue("complexInitializationOrder.kt"); } public void testValuePassedToAncestorConstructor() throws Exception { - testFooBoxIsTrue("valuePassedToAncestorConstructor.kt"); + checkFooBoxIsTrue("valuePassedToAncestorConstructor.kt"); } public void testBaseClassDefinedAfterDerived() throws Exception { - testFooBoxIsTrue("baseClassDefinedAfterDerived.kt"); + checkFooBoxIsTrue("baseClassDefinedAfterDerived.kt"); } public void testDefinitionOrder() throws Exception { - testFooBoxIsTrue("definitionOrder.kt"); + checkFooBoxIsTrue("definitionOrder.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ConditionalTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ConditionalTest.java index 8eaec5f933c..01bc150435f 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ConditionalTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ConditionalTest.java @@ -33,7 +33,7 @@ public class ConditionalTest extends AbstractExpressionTest { public void testIfElseAsExpressionWithThrow() throws Exception { try { - testFooBoxIsTrue("ifAsExpressionWithThrow.kt"); + checkFooBoxIsTrue("ifAsExpressionWithThrow.kt"); fail(); } catch (JavaScriptException e) { diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ExtensionFunctionTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ExtensionFunctionTest.java index 783d67f71ec..428fdad5ed7 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ExtensionFunctionTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ExtensionFunctionTest.java @@ -28,38 +28,38 @@ public final class ExtensionFunctionTest extends TranslationTest { } public void testIntExtension() throws Exception { - testFooBoxIsTrue("intExtension.kt"); + checkFooBoxIsTrue("intExtension.kt"); } public void testExtensionWithImplicitReceiver() throws Exception { - testFooBoxIsTrue("extensionWithImplicitReceiver.kt"); + checkFooBoxIsTrue("extensionWithImplicitReceiver.kt"); } public void testExtensionFunctionOnExpression() throws Exception { - testFooBoxIsTrue("extensionFunctionOnExpression.kt"); + checkFooBoxIsTrue("extensionFunctionOnExpression.kt"); } public void testExtensionUsedInsideClass() throws Exception { - testFooBoxIsTrue("extensionUsedInsideClass.kt"); + checkFooBoxIsTrue("extensionUsedInsideClass.kt"); } public void testVirtualExtension() throws Exception { - testFooBoxIsTrue("virtualExtension.kt"); + checkFooBoxIsTrue("virtualExtension.kt"); } public void testVirtualExtensionOverride() throws Exception { - testFooBoxIsTrue("virtualExtensionOverride.kt"); + checkFooBoxIsTrue("virtualExtensionOverride.kt"); } public void testExtensionLiteralPassedToFunction() throws Exception { - testFooBoxIsTrue("extensionLiteralPassedToFunction.kt"); + checkFooBoxIsTrue("extensionLiteralPassedToFunction.kt"); } public void testExtensionInsideFunctionLiteral() throws Exception { - testFooBoxIsTrue("extensionInsideFunctionLiteral.kt"); + checkFooBoxIsTrue("extensionInsideFunctionLiteral.kt"); } public void testGenericExtension() throws Exception { - testFooBoxIsOk("generic.kt"); + checkFooBoxIsOk("generic.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ExtensionPropertyTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ExtensionPropertyTest.java index 983dd8ab86f..c6387d097bb 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ExtensionPropertyTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ExtensionPropertyTest.java @@ -28,14 +28,14 @@ public final class ExtensionPropertyTest extends TranslationTest { } public void testSimplePropertyWithGetter() throws Exception { - testFooBoxIsTrue("simplePropertyWithGetter.kt"); + checkFooBoxIsTrue("simplePropertyWithGetter.kt"); } public void testPropertyWithGetterAndSetter() throws Exception { - testFooBoxIsTrue("propertyWithGetterAndSetter.kt"); + checkFooBoxIsTrue("propertyWithGetterAndSetter.kt"); } public void testAbsExtension() throws Exception { - testFooBoxIsTrue("absExtension.kt"); + checkFooBoxIsTrue("absExtension.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ForTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ForTest.java index 6c469fc070e..4ea77af1c5d 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ForTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ForTest.java @@ -29,10 +29,10 @@ public final class ForTest extends AbstractExpressionTest { } public void testForIteratesOverArray() throws Exception { - testFooBoxIsTrue("forIteratesOverArray.kt"); + checkFooBoxIsTrue("forIteratesOverArray.kt"); } public void testForOnEmptyArray() throws Exception { - testFooBoxIsTrue("forOnEmptyArray.kt"); + checkFooBoxIsTrue("forOnEmptyArray.kt"); } } \ No newline at end of file diff --git a/js/js.tests/test/org/jetbrains/k2js/test/FunctionTest.java b/js/js.tests/test/org/jetbrains/k2js/test/FunctionTest.java index c339e7343af..f819c841a4d 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/FunctionTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/FunctionTest.java @@ -29,35 +29,35 @@ public class FunctionTest extends AbstractExpressionTest { } public void testFunctionUsedBeforeDeclaration() throws Exception { - testFooBoxIsTrue("functionUsedBeforeDeclaration.kt"); + checkFooBoxIsTrue("functionUsedBeforeDeclaration.kt"); } public void testFunctionWithTwoParametersCall() throws Exception { - testFooBoxIsTrue("functionWithTwoParametersCall.kt"); + checkFooBoxIsTrue("functionWithTwoParametersCall.kt"); } public void testFunctionLiteral() throws Exception { - testFooBoxIsTrue("functionLiteral.kt"); + checkFooBoxIsTrue("functionLiteral.kt"); } public void testAdderClosure() throws Exception { - testFooBoxIsTrue("adderClosure.kt"); + checkFooBoxIsTrue("adderClosure.kt"); } public void testLoopClosure() throws Exception { - testFooBoxIsTrue("loopClosure.kt"); + checkFooBoxIsTrue("loopClosure.kt"); } public void testFunctionLiteralAsParameter() throws Exception { - testFooBoxIsTrue("functionLiteralAsParameter.kt"); + checkFooBoxIsTrue("functionLiteralAsParameter.kt"); } public void testClosureWithParameter() throws Exception { - testFooBoxIsOk("closureWithParameter.kt"); + checkFooBoxIsOk("closureWithParameter.kt"); } public void testClosureWithParameterAndBoxing() throws Exception { - testFooBoxIsOk("closureWithParameterAndBoxing.jet"); + checkFooBoxIsOk("closureWithParameterAndBoxing.jet"); } public void testEnclosingThis() throws Exception { @@ -66,32 +66,32 @@ public class FunctionTest extends AbstractExpressionTest { public void testImplicitItParameter() throws Exception { - testFooBoxIsTrue("implicitItParameter.kt"); + checkFooBoxIsTrue("implicitItParameter.kt"); } public void testDefaultParameters() throws Exception { - testFooBoxIsTrue("defaultParameters.kt"); + checkFooBoxIsTrue("defaultParameters.kt"); } public void testFunctionLiteralAsLastParameter() throws Exception { - testFooBoxIsTrue("functionLiteralAsLastParameter.kt"); + checkFooBoxIsTrue("functionLiteralAsLastParameter.kt"); } public void testNamedArguments() throws Exception { - testFooBoxIsTrue("namedArguments.kt"); + checkFooBoxIsTrue("namedArguments.kt"); } public void testExpressionAsFunction() throws Exception { - testFooBoxIsTrue("expressionAsFunction.kt"); + checkFooBoxIsTrue("expressionAsFunction.kt"); } public void testVararg() throws Exception { - testFooBoxIsTrue("vararg.kt"); + checkFooBoxIsTrue("vararg.kt"); } @@ -104,6 +104,6 @@ public class FunctionTest extends AbstractExpressionTest { } public void testFunctionInsideFunction() throws Exception { - testFooBoxIsTrue("functionInsideFunction.kt"); + checkFooBoxIsTrue("functionInsideFunction.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/MiscTest.java b/js/js.tests/test/org/jetbrains/k2js/test/MiscTest.java index d56a8371b78..b34076ddce0 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/MiscTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/MiscTest.java @@ -36,11 +36,11 @@ public final class MiscTest extends AbstractExpressionTest { public void testIntRange() throws Exception { // checkOutput("intRange.kt", " "); - testFooBoxIsTrue("intRange.kt"); + checkFooBoxIsTrue("intRange.kt"); } public void testSafecallComputesExpressionOnlyOnce() throws Exception { - testFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt"); + checkFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/MultiFileTest.java b/js/js.tests/test/org/jetbrains/k2js/test/MultiFileTest.java index 76738d49285..4b0a375f952 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/MultiFileTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/MultiFileTest.java @@ -29,15 +29,15 @@ public final class MultiFileTest extends TranslationTest { } public void testFunctionsVisibleFromOtherFile() throws Exception { - testFooBoxIsTrue("functionsVisibleFromOtherFile"); + checkFooBoxIsTrue("functionsVisibleFromOtherFile"); } public void testClassesInheritedFromOtherFile() throws Exception { - testFooBoxIsTrue("classesInheritedFromOtherFile"); + checkFooBoxIsTrue("classesInheritedFromOtherFile"); } @Override - public void testFooBoxIsTrue(String dirName) throws Exception { + public void checkFooBoxIsTrue(String dirName) throws Exception { testMultiFile(dirName, "foo", "box", true); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/MultiNamespaceTest.java b/js/js.tests/test/org/jetbrains/k2js/test/MultiNamespaceTest.java index 8d7d473d636..cdc9b928b36 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/MultiNamespaceTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/MultiNamespaceTest.java @@ -28,15 +28,15 @@ public class MultiNamespaceTest extends TranslationTest { } public void testFunctionsVisibleFromOtherNamespace() throws Exception { - testFooBoxIsTrue("functionsVisibleFromOtherNamespace"); + checkFooBoxIsTrue("functionsVisibleFromOtherNamespace"); } public void testClassesInheritedFromOtherNamespace() throws Exception { - testFooBoxIsTrue("classesInheritedFromOtherNamespace"); + checkFooBoxIsTrue("classesInheritedFromOtherNamespace"); } @Override - public void testFooBoxIsTrue(String dirName) throws Exception { + public void checkFooBoxIsTrue(String dirName) throws Exception { testMultiFile(dirName, "foo", "box", true); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/NameClashesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/NameClashesTest.java index 67f563d2430..c3c7d2c5bc8 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/NameClashesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/NameClashesTest.java @@ -29,6 +29,6 @@ public final class NameClashesTest extends TranslationTest { } public void testMethodOverload() throws Exception { - testFooBoxIsTrue("methodOverload.kt"); + checkFooBoxIsTrue("methodOverload.kt"); } } \ No newline at end of file diff --git a/js/js.tests/test/org/jetbrains/k2js/test/ObjectTest.java b/js/js.tests/test/org/jetbrains/k2js/test/ObjectTest.java index f0824057fdc..c40cebca8fa 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/ObjectTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/ObjectTest.java @@ -30,16 +30,16 @@ public final class ObjectTest extends TranslationTest { public void testObjectWithMethods() throws Exception { - testFooBoxIsTrue("objectWithMethods.kt"); + checkFooBoxIsTrue("objectWithMethods.kt"); } public void testObjectDeclaration() throws Exception { - testFooBoxIsTrue("objectDeclaration.kt"); + checkFooBoxIsTrue("objectDeclaration.kt"); } public void testObjectInMethod() throws Exception { - testFooBoxIsTrue("objectInMethod.kt"); + checkFooBoxIsTrue("objectInMethod.kt"); } } \ No newline at end of file diff --git a/js/js.tests/test/org/jetbrains/k2js/test/OperatorOverloadingTest.java b/js/js.tests/test/org/jetbrains/k2js/test/OperatorOverloadingTest.java index d36e34ed211..61a0fe93124 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/OperatorOverloadingTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/OperatorOverloadingTest.java @@ -30,79 +30,79 @@ public final class OperatorOverloadingTest extends TranslationTest { public void testPlusOverload() throws Exception { - testFooBoxIsTrue("plusOverload.kt"); + checkFooBoxIsTrue("plusOverload.kt"); } public void testPostfixInc() throws Exception { - testFooBoxIsTrue("postfixIncOverload.kt"); + checkFooBoxIsTrue("postfixIncOverload.kt"); } public void testPrefixDecOverload() throws Exception { - testFooBoxIsTrue("prefixDecOverload.kt"); + checkFooBoxIsTrue("prefixDecOverload.kt"); } public void testPrefixIncReturnsCorrectValue() throws Exception { - testFooBoxIsTrue("prefixIncReturnsCorrectValue.kt"); + checkFooBoxIsTrue("prefixIncReturnsCorrectValue.kt"); } public void testOverloadedCallOnProperty() throws Exception { - testFooBoxIsTrue("overloadedCallOnProperty.kt"); + checkFooBoxIsTrue("overloadedCallOnProperty.kt"); } public void testPostfixOnProperty() throws Exception { - testFooBoxIsTrue("postfixOnProperty.kt"); + checkFooBoxIsTrue("postfixOnProperty.kt"); } public void testOperatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception { - testFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt"); + checkFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt"); } public void testUnaryOnIntProperty() throws Exception { - testFooBoxIsTrue("unaryOnIntProperty.kt"); + checkFooBoxIsTrue("unaryOnIntProperty.kt"); } public void testUnaryOnIntPropertyAsStatement() throws Exception { - testFooBoxIsTrue("unaryOnIntProperty2.kt"); + checkFooBoxIsTrue("unaryOnIntProperty2.kt"); } public void testBinaryDivOverload() throws Exception { - testFooBoxIsTrue("binaryDivOverload.kt"); + checkFooBoxIsTrue("binaryDivOverload.kt"); } public void testPlusAssignNoReassign() throws Exception { - testFooBoxIsTrue("plusAssignNoReassign.kt"); + checkFooBoxIsTrue("plusAssignNoReassign.kt"); } public void testNotOverload() throws Exception { - testFooBoxIsTrue("notOverload.kt"); + checkFooBoxIsTrue("notOverload.kt"); } public void testCompareTo() throws Exception { - testFooBoxIsTrue("compareTo.kt"); + checkFooBoxIsTrue("compareTo.kt"); } public void testPlusAndMinusAsAnExpression() throws Exception { - testFooBoxIsTrue("plusAndMinusAsAnExpression.kt"); + checkFooBoxIsTrue("plusAndMinusAsAnExpression.kt"); } public void testUsingModInCaseModAssignNotAvailable() throws Exception { - testFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt"); + checkFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt"); } public void testOverloadPlusAssignArrayList() throws Exception { - testFooBoxIsOk("overloadPlusAssignArrayList.kt"); + checkFooBoxIsOk("overloadPlusAssignArrayList.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/PatternMatchingTest.java b/js/js.tests/test/org/jetbrains/k2js/test/PatternMatchingTest.java index d9ff84c1b0e..7bb03d3fd06 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/PatternMatchingTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/PatternMatchingTest.java @@ -32,37 +32,37 @@ public final class PatternMatchingTest extends TranslationTest { public void testWhenType() throws Exception { - testFooBoxIsTrue("whenType.kt"); + checkFooBoxIsTrue("whenType.kt"); } public void testWhenNotType() throws Exception { - testFooBoxIsTrue("whenNotType.kt"); + checkFooBoxIsTrue("whenNotType.kt"); } public void testWhenExecutesOnlyOnce() throws Exception { - testFooBoxIsTrue("whenExecutesOnlyOnce.kt"); + checkFooBoxIsTrue("whenExecutesOnlyOnce.kt"); } public void testWhenValue() throws Exception { - testFooBoxIsTrue("whenValue.kt"); + checkFooBoxIsTrue("whenValue.kt"); } public void testWhenNotValue() throws Exception { - testFooBoxIsTrue("whenNotValue.kt"); + checkFooBoxIsTrue("whenNotValue.kt"); } public void testWhenValueOrType() throws Exception { - testFooBoxIsTrue("whenValueOrType.kt"); + checkFooBoxIsTrue("whenValueOrType.kt"); } public void testWhenWithIf() throws Exception { - testFooBoxIsTrue("whenWithIf.kt"); + checkFooBoxIsTrue("whenWithIf.kt"); } @@ -72,17 +72,17 @@ public final class PatternMatchingTest extends TranslationTest { public void testMatchNullableType() throws Exception { - testFooBoxIsTrue("matchNullableType.kt"); + checkFooBoxIsTrue("matchNullableType.kt"); } public void testWhenAsExpression() throws Exception { - testFooBoxIsTrue("whenAsExpression.kt"); + checkFooBoxIsTrue("whenAsExpression.kt"); } public void whenAsExpressionWithThrow() throws Exception { try { - testFooBoxIsTrue("whenAsExpressionWithThrow.kt"); + checkFooBoxIsTrue("whenAsExpressionWithThrow.kt"); fail(); } catch (JavaScriptException e) { } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/PropertyAccessTest.java b/js/js.tests/test/org/jetbrains/k2js/test/PropertyAccessTest.java index d08b4b1dd52..78d7e0243dc 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/PropertyAccessTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/PropertyAccessTest.java @@ -30,12 +30,12 @@ public final class PropertyAccessTest extends TranslationTest { public void testAccessToInstanceProperty() throws Exception { - testFooBoxIsTrue("accessToInstanceProperty.kt"); + checkFooBoxIsTrue("accessToInstanceProperty.kt"); } public void testTwoClassesWithProperties() throws Exception { - testFooBoxIsTrue("twoClassesWithProperties.kt"); + checkFooBoxIsTrue("twoClassesWithProperties.kt"); } @@ -45,55 +45,55 @@ public final class PropertyAccessTest extends TranslationTest { public void testCustomGetter() throws Exception { - testFooBoxIsTrue("customGetter.kt"); + checkFooBoxIsTrue("customGetter.kt"); } public void testCustomSetter() throws Exception { - testFooBoxIsTrue("customSetter.kt"); + checkFooBoxIsTrue("customSetter.kt"); } public void testSafeCall() throws Exception { - testFooBoxIsTrue("safeCall.kt"); + checkFooBoxIsTrue("safeCall.kt"); } //TODO: place safecalls under distinkt category public void testSafeCallReturnsNullIfFails() throws Exception { - testFooBoxIsTrue("safeCallReturnsNullIfFails.kt"); + checkFooBoxIsTrue("safeCallReturnsNullIfFails.kt"); } public void testNamespacePropertyInitializer() throws Exception { - testFooBoxIsTrue("namespacePropertyInitializer.kt"); + checkFooBoxIsTrue("namespacePropertyInitializer.kt"); } public void testNamespacePropertySet() throws Exception { - testFooBoxIsTrue("namespacePropertySet.kt"); + checkFooBoxIsTrue("namespacePropertySet.kt"); } public void testNamespaceCustomAccessors() throws Exception { - testFooBoxIsTrue("namespaceCustomAccessors.kt"); + checkFooBoxIsTrue("namespaceCustomAccessors.kt"); } public void testClassUsesNamespaceProperties() throws Exception { - testFooBoxIsTrue("classUsesNamespaceProperties.kt"); + checkFooBoxIsTrue("classUsesNamespaceProperties.kt"); } public void testSafeAccess() throws Exception { - testFooBoxIsTrue("safeAccess.kt"); + checkFooBoxIsTrue("safeAccess.kt"); } public void testSafeExtensionFunctionCall() throws Exception { - testFooBoxIsOk("safeExtensionFunctionCall.kt"); + checkFooBoxIsOk("safeExtensionFunctionCall.kt"); } public void testExtensionLiteralSafeCall() throws Exception { - testFooBoxIsTrue("extensionLiteralSafeCall.kt"); + checkFooBoxIsTrue("extensionLiteralSafeCall.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/RTTITest.java b/js/js.tests/test/org/jetbrains/k2js/test/RTTITest.java index 03ea3e85b9c..2529fbcc5ee 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/RTTITest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/RTTITest.java @@ -29,10 +29,10 @@ public class RTTITest extends TranslationTest { } public void testIsSameClass() throws Exception { - testFooBoxIsTrue("isSameClass.kt"); + checkFooBoxIsTrue("isSameClass.kt"); } public void testNotIsOtherClass() throws Exception { - testFooBoxIsTrue("notIsOtherClass.kt"); + checkFooBoxIsTrue("notIsOtherClass.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/RangeTest.java b/js/js.tests/test/org/jetbrains/k2js/test/RangeTest.java index fe3b89d2756..6fbc5269a41 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/RangeTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/RangeTest.java @@ -30,20 +30,20 @@ public final class RangeTest extends TranslationTest { public void testExplicitRange() throws Exception { - testFooBoxIsTrue("explicitRange.kt"); + checkFooBoxIsTrue("explicitRange.kt"); } public void testRangeSugarSyntax() throws Exception { - testFooBoxIsTrue("rangeSugarSyntax.kt"); + checkFooBoxIsTrue("rangeSugarSyntax.kt"); } public void testIntInRange() throws Exception { - testFooBoxIsTrue("intInRange.kt"); + checkFooBoxIsTrue("intInRange.kt"); } public void testIteratingOverRanges() throws Exception { - testFooBoxIsTrue("iteratingOverRanges.kt"); + checkFooBoxIsTrue("iteratingOverRanges.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/SimpleTestSuite.java b/js/js.tests/test/org/jetbrains/k2js/test/SimpleTestSuite.java index 6f8f741ca4f..5b7637a36ba 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/SimpleTestSuite.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/SimpleTestSuite.java @@ -29,7 +29,7 @@ public final class SimpleTestSuite extends UsefulTestCase { return Suite.suiteForDirectory("simple/", new Suite.SingleFileTester() { @Override public void performTest(@NotNull Suite test, @NotNull String filename) throws Exception { - test.testFooBoxIsTrue(filename); + test.checkFooBoxIsTrue(filename); } }); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/StandardClassesTest.java b/js/js.tests/test/org/jetbrains/k2js/test/StandardClassesTest.java index 95b2cbedcf1..51578051cc4 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/StandardClassesTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/StandardClassesTest.java @@ -29,38 +29,38 @@ public class StandardClassesTest extends TranslationTest { public void testArray() throws Exception { - testFooBoxIsTrue("array.kt"); + checkFooBoxIsTrue("array.kt"); } public void testArrayAccess() throws Exception { - testFooBoxIsTrue("arrayAccess.kt"); + checkFooBoxIsTrue("arrayAccess.kt"); } public void testArrayIsFilledWithNulls() throws Exception { - testFooBoxIsTrue("arrayIsFilledWithNulls.kt"); + checkFooBoxIsTrue("arrayIsFilledWithNulls.kt"); } public void testArrayFunctionConstructor() throws Exception { - testFooBoxIsTrue("arrayFunctionConstructor.kt"); + checkFooBoxIsTrue("arrayFunctionConstructor.kt"); } public void testArraySize() throws Exception { - testFooBoxIsTrue("arraySize.kt"); + checkFooBoxIsTrue("arraySize.kt"); } //TODO: this feature in not supported for some time //TODO: support it. Probably configurable. // (expected = JavaScriptException.class) // public void arrayThrowsExceptionOnOOBaccess() throws Exception { -// testFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt"); +// checkFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt"); // } public void testArraysIterator() throws Exception { - testFooBoxIsTrue("arraysIterator.kt"); + checkFooBoxIsTrue("arraysIterator.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/StringTest.java b/js/js.tests/test/org/jetbrains/k2js/test/StringTest.java index bf45441f9e7..b01412c5f06 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/StringTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/StringTest.java @@ -29,11 +29,11 @@ public class StringTest extends AbstractExpressionTest { } public void testStringConstant() throws Exception { - testFooBoxIsTrue("stringConstant.kt"); + checkFooBoxIsTrue("stringConstant.kt"); } public void testStringAssignment() throws Exception { - testFooBoxIsTrue("stringAssignment.kt"); + checkFooBoxIsTrue("stringAssignment.kt"); } public void testIntInTemplate() throws Exception { @@ -49,6 +49,6 @@ public class StringTest extends AbstractExpressionTest { } public void testToStringMethod() throws Exception { - testFooBoxIsTrue("objectToStringCallInTemplate.kt"); + checkFooBoxIsTrue("objectToStringCallInTemplate.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/TraitTest.java b/js/js.tests/test/org/jetbrains/k2js/test/TraitTest.java index f58d18d038f..0363121db1c 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/TraitTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/TraitTest.java @@ -30,41 +30,41 @@ public final class TraitTest extends TranslationTest { public void testTraitAddsFunctionsToClass() throws Exception { - testFooBoxIsTrue("traitAddsFunctionsToClass.kt"); + checkFooBoxIsTrue("traitAddsFunctionsToClass.kt"); } public void testClassDerivesFromClassAndTrait() throws Exception { - testFooBoxIsTrue("classDerivesFromClassAndTrait.kt"); + checkFooBoxIsTrue("classDerivesFromClassAndTrait.kt"); } public void testClassDerivesFromTraitAndClass() throws Exception { - testFooBoxIsTrue("classDerivesFromTraitAndClass.kt"); + checkFooBoxIsTrue("classDerivesFromTraitAndClass.kt"); } public void testExample() throws Exception { - testFooBoxIsTrue("example.kt"); + checkFooBoxIsTrue("example.kt"); } public void testTraitExtendsTrait() throws Exception { - testFooBoxIsTrue("traitExtendsTrait.kt"); + checkFooBoxIsTrue("traitExtendsTrait.kt"); } public void testTraitExtendsTwoTraits() throws Exception { - testFooBoxIsTrue("traitExtendsTwoTraits.kt"); + checkFooBoxIsTrue("traitExtendsTwoTraits.kt"); } public void testFunDelegation() throws Exception { - testFooBoxIsOk("funDelegation.jet"); + checkFooBoxIsOk("funDelegation.jet"); } public void testDefinitionOrder() throws Exception { - testFooBoxIsTrue("definitionOrder.kt"); + checkFooBoxIsTrue("definitionOrder.kt"); } } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/TranslationTest.java b/js/js.tests/test/org/jetbrains/k2js/test/TranslationTest.java index bbb77c11318..cd3a6d72a54 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/TranslationTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/TranslationTest.java @@ -17,6 +17,7 @@ package org.jetbrains.k2js.test; import com.google.dart.compiler.backend.js.ast.JsProgram; +import com.intellij.openapi.util.io.FileUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.k2js.facade.K2JSTranslator; @@ -27,9 +28,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.IOException; -import java.nio.MappedByteBuffer; -import java.nio.channels.FileChannel; -import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -158,13 +156,17 @@ public abstract class TranslationTest extends BaseTest { return getExpectedPath() + testName + ".out"; } - protected void runFileWithRhino(String inputFile, Context context, Scriptable scope) throws Exception { + protected static void runFileWithRhino(String inputFile, Context context, Scriptable scope) throws Exception { FileReader reader = new FileReader(inputFile); - context.evaluateReader(scope, reader, inputFile, 1, null); - reader.close(); + try { + context.evaluateReader(scope, reader, inputFile, 1, null); + } finally { + reader.close(); + } } - protected void runRhinoTest(List fileNames, RhinoResultChecker checker) throws Exception { + protected static void runRhinoTest(@NotNull List fileNames, + @NotNull RhinoResultChecker checker) throws Exception { Context context = Context.enter(); Scriptable scope = context.initStandardObjects(); for (String filename : fileNames) { @@ -174,11 +176,11 @@ public abstract class TranslationTest extends BaseTest { Context.exit(); } - public void testFooBoxIsTrue(String filename) throws Exception { + public void checkFooBoxIsTrue(String filename) throws Exception { testFunctionOutput(filename, "foo", "box", true); } - public void testFooBoxIsOk(String filename) throws Exception { + public void checkFooBoxIsOk(String filename) throws Exception { testFunctionOutput(filename, "foo", "box", "OK"); } @@ -188,21 +190,16 @@ public abstract class TranslationTest extends BaseTest { new RhinoSystemOutputChecker(expectedResult, Arrays.asList(args))); } - protected void testWithMain(String testName, String testId, String... args) throws Exception { + protected void performTestWithMain(String testName, String testId, String... args) throws Exception { checkOutput(testName + ".kt", readFile(expected(testName + testId)), args); } private static String readFile(String path) throws IOException { FileInputStream stream = new FileInputStream(new File(path)); try { - FileChannel fc = stream.getChannel(); - MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size()); - /* Instead of using default, pass in a decoder. */ - return Charset.defaultCharset().decode(bb).toString(); + return FileUtil.loadTextAndClose(stream); } finally { stream.close(); } } - - } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/TupleTest.java b/js/js.tests/test/org/jetbrains/k2js/test/TupleTest.java index d40b350d90f..e2e18fbe6e8 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/TupleTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/TupleTest.java @@ -29,11 +29,11 @@ public final class TupleTest extends TranslationTest { } public void testTwoElements() throws Exception { - testFooBoxIsTrue("twoElements.kt"); + checkFooBoxIsTrue("twoElements.kt"); } public void testMultipleMembers() throws Exception { - testFooBoxIsTrue("multipleMembers.kt"); + checkFooBoxIsTrue("multipleMembers.kt"); } diff --git a/js/js.tests/test/org/jetbrains/k2js/test/WebDemoExamples2Test.java b/js/js.tests/test/org/jetbrains/k2js/test/WebDemoExamples2Test.java index 1eb409c2b8a..cd9da6a45b3 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/WebDemoExamples2Test.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/WebDemoExamples2Test.java @@ -29,22 +29,22 @@ public final class WebDemoExamples2Test extends TranslationTest { } public void testBottles() throws Exception { - testWithMain("bottles", "2", "2"); - testWithMain("bottles", ""); + performTestWithMain("bottles", "2", "2"); + performTestWithMain("bottles", ""); } public void testLife() throws Exception { - testWithMain("life", "", "2"); + performTestWithMain("life", "", "2"); } public void testBuilder() throws Exception { - testWithMain("builder", ""); - testWithMain("builder", "1", "over9000"); + performTestWithMain("builder", ""); + performTestWithMain("builder", "1", "over9000"); } //TODO: comparator LinkedList dependencies // @Test // public void maze() throws Exception { -// testWithMain("maze", ""); +// performTestWithMain("maze", ""); // } } diff --git a/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java b/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java index fe744752b94..09461d0d0f8 100644 --- a/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java +++ b/js/js.translator/src/org/jetbrains/k2js/facade/K2JSTranslator.java @@ -61,8 +61,11 @@ public final class K2JSTranslator { } String callToMain = translator.generateCallToMain(fileWithMain, ""); FileWriter writer = new FileWriter(new File(outputPath)); - writer.write(programCode + callToMain); - writer.close(); + try { + writer.write(programCode + callToMain); + } finally { + writer.close(); + } } public static void saveProgramToFile(@NotNull String outputFile, @NotNull JsProgram program) throws IOException { @@ -79,6 +82,8 @@ public final class K2JSTranslator { } //TODO: refactor + //TODO: web demo related method + @SuppressWarnings("UnusedDeclaration") @NotNull public String translateStringWithCallToMain(@NotNull String programText, @NotNull String argumentsString) { JetFile file = JetFileUtils.createPsiFile("test", programText, getProject()); @@ -103,6 +108,8 @@ public final class K2JSTranslator { return generator.generateToString(program); } + //TODO: relates to web demo + @SuppressWarnings("UnusedDeclaration") @NotNull public BindingContext analyzeProgramCode(@NotNull String programText) { JetFile file = JetFileUtils.createPsiFile("test", programText, getProject()); @@ -126,7 +133,7 @@ public final class K2JSTranslator { } @NotNull - private List parseString(@NotNull String argumentString) { + private static List parseString(@NotNull String argumentString) { List result = new ArrayList(); StringTokenizer stringTokenizer = new StringTokenizer(argumentString); while (stringTokenizer.hasMoreTokens()) {