Refactor js.tests.
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
<sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="1.6" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="js.translator" />
|
<orderEntry type="module" module-name="js.translator" />
|
||||||
<orderEntry type="module" module-name="compiler-tests" />
|
<orderEntry type="module" module-name="compiler-tests" />
|
||||||
|
|||||||
@@ -31,32 +31,32 @@ public final class ArrayListTest extends JavaClassesTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testEmptyList() throws Exception {
|
public void testEmptyList() throws Exception {
|
||||||
testFooBoxIsTrue("emptyList.kt");
|
checkFooBoxIsTrue("emptyList.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAccess() throws Exception {
|
public void testAccess() throws Exception {
|
||||||
testFooBoxIsTrue("access.kt");
|
checkFooBoxIsTrue("access.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIsEmpty() throws Exception {
|
public void testIsEmpty() throws Exception {
|
||||||
testFooBoxIsTrue("isEmpty.kt");
|
checkFooBoxIsTrue("isEmpty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testArrayAccess() throws Exception {
|
public void testArrayAccess() throws Exception {
|
||||||
testFooBoxIsTrue("arrayAccess.kt");
|
checkFooBoxIsTrue("arrayAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIterate() throws Exception {
|
public void testIterate() throws Exception {
|
||||||
testFooBoxIsTrue("iterate.kt");
|
checkFooBoxIsTrue("iterate.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testRemove() throws Exception {
|
public void testRemove() throws Exception {
|
||||||
testFooBoxIsTrue("remove.kt");
|
checkFooBoxIsTrue("remove.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIndexOOB() throws Exception {
|
public void testIndexOOB() throws Exception {
|
||||||
try {
|
try {
|
||||||
testFooBoxIsTrue("indexOOB.kt");
|
checkFooBoxIsTrue("indexOOB.kt");
|
||||||
fail();
|
fail();
|
||||||
} catch (JavaScriptException e) {
|
} catch (JavaScriptException e) {
|
||||||
|
|
||||||
|
|||||||
@@ -33,27 +33,27 @@ public final class ClassInheritanceTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodOverride() throws Exception {
|
public void testMethodOverride() throws Exception {
|
||||||
testFooBoxIsTrue("methodOverride.kt");
|
checkFooBoxIsTrue("methodOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testInitializationOrder() throws Exception {
|
public void testInitializationOrder() throws Exception {
|
||||||
testFooBoxIsTrue("initializationOrder.kt");
|
checkFooBoxIsTrue("initializationOrder.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testComplexInitializationOrder() throws Exception {
|
public void testComplexInitializationOrder() throws Exception {
|
||||||
testFooBoxIsTrue("complexInitializationOrder.kt");
|
checkFooBoxIsTrue("complexInitializationOrder.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testValuePassedToAncestorConstructor() throws Exception {
|
public void testValuePassedToAncestorConstructor() throws Exception {
|
||||||
testFooBoxIsTrue("valuePassedToAncestorConstructor.kt");
|
checkFooBoxIsTrue("valuePassedToAncestorConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBaseClassDefinedAfterDerived() throws Exception {
|
public void testBaseClassDefinedAfterDerived() throws Exception {
|
||||||
testFooBoxIsTrue("baseClassDefinedAfterDerived.kt");
|
checkFooBoxIsTrue("baseClassDefinedAfterDerived.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDefinitionOrder() throws Exception {
|
public void testDefinitionOrder() throws Exception {
|
||||||
testFooBoxIsTrue("definitionOrder.kt");
|
checkFooBoxIsTrue("definitionOrder.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class ConditionalTest extends AbstractExpressionTest {
|
|||||||
|
|
||||||
public void testIfElseAsExpressionWithThrow() throws Exception {
|
public void testIfElseAsExpressionWithThrow() throws Exception {
|
||||||
try {
|
try {
|
||||||
testFooBoxIsTrue("ifAsExpressionWithThrow.kt");
|
checkFooBoxIsTrue("ifAsExpressionWithThrow.kt");
|
||||||
fail();
|
fail();
|
||||||
} catch (JavaScriptException e) {
|
} catch (JavaScriptException e) {
|
||||||
|
|
||||||
|
|||||||
@@ -28,38 +28,38 @@ public final class ExtensionFunctionTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIntExtension() throws Exception {
|
public void testIntExtension() throws Exception {
|
||||||
testFooBoxIsTrue("intExtension.kt");
|
checkFooBoxIsTrue("intExtension.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionWithImplicitReceiver() throws Exception {
|
public void testExtensionWithImplicitReceiver() throws Exception {
|
||||||
testFooBoxIsTrue("extensionWithImplicitReceiver.kt");
|
checkFooBoxIsTrue("extensionWithImplicitReceiver.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionFunctionOnExpression() throws Exception {
|
public void testExtensionFunctionOnExpression() throws Exception {
|
||||||
testFooBoxIsTrue("extensionFunctionOnExpression.kt");
|
checkFooBoxIsTrue("extensionFunctionOnExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionUsedInsideClass() throws Exception {
|
public void testExtensionUsedInsideClass() throws Exception {
|
||||||
testFooBoxIsTrue("extensionUsedInsideClass.kt");
|
checkFooBoxIsTrue("extensionUsedInsideClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVirtualExtension() throws Exception {
|
public void testVirtualExtension() throws Exception {
|
||||||
testFooBoxIsTrue("virtualExtension.kt");
|
checkFooBoxIsTrue("virtualExtension.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testVirtualExtensionOverride() throws Exception {
|
public void testVirtualExtensionOverride() throws Exception {
|
||||||
testFooBoxIsTrue("virtualExtensionOverride.kt");
|
checkFooBoxIsTrue("virtualExtensionOverride.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionLiteralPassedToFunction() throws Exception {
|
public void testExtensionLiteralPassedToFunction() throws Exception {
|
||||||
testFooBoxIsTrue("extensionLiteralPassedToFunction.kt");
|
checkFooBoxIsTrue("extensionLiteralPassedToFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionInsideFunctionLiteral() throws Exception {
|
public void testExtensionInsideFunctionLiteral() throws Exception {
|
||||||
testFooBoxIsTrue("extensionInsideFunctionLiteral.kt");
|
checkFooBoxIsTrue("extensionInsideFunctionLiteral.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGenericExtension() throws Exception {
|
public void testGenericExtension() throws Exception {
|
||||||
testFooBoxIsOk("generic.kt");
|
checkFooBoxIsOk("generic.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,14 +28,14 @@ public final class ExtensionPropertyTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testSimplePropertyWithGetter() throws Exception {
|
public void testSimplePropertyWithGetter() throws Exception {
|
||||||
testFooBoxIsTrue("simplePropertyWithGetter.kt");
|
checkFooBoxIsTrue("simplePropertyWithGetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPropertyWithGetterAndSetter() throws Exception {
|
public void testPropertyWithGetterAndSetter() throws Exception {
|
||||||
testFooBoxIsTrue("propertyWithGetterAndSetter.kt");
|
checkFooBoxIsTrue("propertyWithGetterAndSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAbsExtension() throws Exception {
|
public void testAbsExtension() throws Exception {
|
||||||
testFooBoxIsTrue("absExtension.kt");
|
checkFooBoxIsTrue("absExtension.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ public final class ForTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testForIteratesOverArray() throws Exception {
|
public void testForIteratesOverArray() throws Exception {
|
||||||
testFooBoxIsTrue("forIteratesOverArray.kt");
|
checkFooBoxIsTrue("forIteratesOverArray.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testForOnEmptyArray() throws Exception {
|
public void testForOnEmptyArray() throws Exception {
|
||||||
testFooBoxIsTrue("forOnEmptyArray.kt");
|
checkFooBoxIsTrue("forOnEmptyArray.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -29,35 +29,35 @@ public class FunctionTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionUsedBeforeDeclaration() throws Exception {
|
public void testFunctionUsedBeforeDeclaration() throws Exception {
|
||||||
testFooBoxIsTrue("functionUsedBeforeDeclaration.kt");
|
checkFooBoxIsTrue("functionUsedBeforeDeclaration.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionWithTwoParametersCall() throws Exception {
|
public void testFunctionWithTwoParametersCall() throws Exception {
|
||||||
testFooBoxIsTrue("functionWithTwoParametersCall.kt");
|
checkFooBoxIsTrue("functionWithTwoParametersCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionLiteral() throws Exception {
|
public void testFunctionLiteral() throws Exception {
|
||||||
testFooBoxIsTrue("functionLiteral.kt");
|
checkFooBoxIsTrue("functionLiteral.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testAdderClosure() throws Exception {
|
public void testAdderClosure() throws Exception {
|
||||||
testFooBoxIsTrue("adderClosure.kt");
|
checkFooBoxIsTrue("adderClosure.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLoopClosure() throws Exception {
|
public void testLoopClosure() throws Exception {
|
||||||
testFooBoxIsTrue("loopClosure.kt");
|
checkFooBoxIsTrue("loopClosure.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionLiteralAsParameter() throws Exception {
|
public void testFunctionLiteralAsParameter() throws Exception {
|
||||||
testFooBoxIsTrue("functionLiteralAsParameter.kt");
|
checkFooBoxIsTrue("functionLiteralAsParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClosureWithParameter() throws Exception {
|
public void testClosureWithParameter() throws Exception {
|
||||||
testFooBoxIsOk("closureWithParameter.kt");
|
checkFooBoxIsOk("closureWithParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClosureWithParameterAndBoxing() throws Exception {
|
public void testClosureWithParameterAndBoxing() throws Exception {
|
||||||
testFooBoxIsOk("closureWithParameterAndBoxing.jet");
|
checkFooBoxIsOk("closureWithParameterAndBoxing.jet");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testEnclosingThis() throws Exception {
|
public void testEnclosingThis() throws Exception {
|
||||||
@@ -66,32 +66,32 @@ public class FunctionTest extends AbstractExpressionTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testImplicitItParameter() throws Exception {
|
public void testImplicitItParameter() throws Exception {
|
||||||
testFooBoxIsTrue("implicitItParameter.kt");
|
checkFooBoxIsTrue("implicitItParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testDefaultParameters() throws Exception {
|
public void testDefaultParameters() throws Exception {
|
||||||
testFooBoxIsTrue("defaultParameters.kt");
|
checkFooBoxIsTrue("defaultParameters.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testFunctionLiteralAsLastParameter() throws Exception {
|
public void testFunctionLiteralAsLastParameter() throws Exception {
|
||||||
testFooBoxIsTrue("functionLiteralAsLastParameter.kt");
|
checkFooBoxIsTrue("functionLiteralAsLastParameter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testNamedArguments() throws Exception {
|
public void testNamedArguments() throws Exception {
|
||||||
testFooBoxIsTrue("namedArguments.kt");
|
checkFooBoxIsTrue("namedArguments.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testExpressionAsFunction() throws Exception {
|
public void testExpressionAsFunction() throws Exception {
|
||||||
testFooBoxIsTrue("expressionAsFunction.kt");
|
checkFooBoxIsTrue("expressionAsFunction.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testVararg() throws Exception {
|
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 {
|
public void testFunctionInsideFunction() throws Exception {
|
||||||
testFooBoxIsTrue("functionInsideFunction.kt");
|
checkFooBoxIsTrue("functionInsideFunction.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ public final class MiscTest extends AbstractExpressionTest {
|
|||||||
|
|
||||||
public void testIntRange() throws Exception {
|
public void testIntRange() throws Exception {
|
||||||
// checkOutput("intRange.kt", " ");
|
// checkOutput("intRange.kt", " ");
|
||||||
testFooBoxIsTrue("intRange.kt");
|
checkFooBoxIsTrue("intRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSafecallComputesExpressionOnlyOnce() throws Exception {
|
public void testSafecallComputesExpressionOnlyOnce() throws Exception {
|
||||||
testFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt");
|
checkFooBoxIsTrue("safecallComputesExpressionOnlyOnce.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,15 +29,15 @@ public final class MultiFileTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionsVisibleFromOtherFile() throws Exception {
|
public void testFunctionsVisibleFromOtherFile() throws Exception {
|
||||||
testFooBoxIsTrue("functionsVisibleFromOtherFile");
|
checkFooBoxIsTrue("functionsVisibleFromOtherFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassesInheritedFromOtherFile() throws Exception {
|
public void testClassesInheritedFromOtherFile() throws Exception {
|
||||||
testFooBoxIsTrue("classesInheritedFromOtherFile");
|
checkFooBoxIsTrue("classesInheritedFromOtherFile");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testFooBoxIsTrue(String dirName) throws Exception {
|
public void checkFooBoxIsTrue(String dirName) throws Exception {
|
||||||
testMultiFile(dirName, "foo", "box", true);
|
testMultiFile(dirName, "foo", "box", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,15 +28,15 @@ public class MultiNamespaceTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testFunctionsVisibleFromOtherNamespace() throws Exception {
|
public void testFunctionsVisibleFromOtherNamespace() throws Exception {
|
||||||
testFooBoxIsTrue("functionsVisibleFromOtherNamespace");
|
checkFooBoxIsTrue("functionsVisibleFromOtherNamespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testClassesInheritedFromOtherNamespace() throws Exception {
|
public void testClassesInheritedFromOtherNamespace() throws Exception {
|
||||||
testFooBoxIsTrue("classesInheritedFromOtherNamespace");
|
checkFooBoxIsTrue("classesInheritedFromOtherNamespace");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void testFooBoxIsTrue(String dirName) throws Exception {
|
public void checkFooBoxIsTrue(String dirName) throws Exception {
|
||||||
testMultiFile(dirName, "foo", "box", true);
|
testMultiFile(dirName, "foo", "box", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,6 @@ public final class NameClashesTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testMethodOverload() throws Exception {
|
public void testMethodOverload() throws Exception {
|
||||||
testFooBoxIsTrue("methodOverload.kt");
|
checkFooBoxIsTrue("methodOverload.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,16 +30,16 @@ public final class ObjectTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testObjectWithMethods() throws Exception {
|
public void testObjectWithMethods() throws Exception {
|
||||||
testFooBoxIsTrue("objectWithMethods.kt");
|
checkFooBoxIsTrue("objectWithMethods.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testObjectDeclaration() throws Exception {
|
public void testObjectDeclaration() throws Exception {
|
||||||
testFooBoxIsTrue("objectDeclaration.kt");
|
checkFooBoxIsTrue("objectDeclaration.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testObjectInMethod() throws Exception {
|
public void testObjectInMethod() throws Exception {
|
||||||
testFooBoxIsTrue("objectInMethod.kt");
|
checkFooBoxIsTrue("objectInMethod.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -30,79 +30,79 @@ public final class OperatorOverloadingTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testPlusOverload() throws Exception {
|
public void testPlusOverload() throws Exception {
|
||||||
testFooBoxIsTrue("plusOverload.kt");
|
checkFooBoxIsTrue("plusOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPostfixInc() throws Exception {
|
public void testPostfixInc() throws Exception {
|
||||||
testFooBoxIsTrue("postfixIncOverload.kt");
|
checkFooBoxIsTrue("postfixIncOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPrefixDecOverload() throws Exception {
|
public void testPrefixDecOverload() throws Exception {
|
||||||
testFooBoxIsTrue("prefixDecOverload.kt");
|
checkFooBoxIsTrue("prefixDecOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPrefixIncReturnsCorrectValue() throws Exception {
|
public void testPrefixIncReturnsCorrectValue() throws Exception {
|
||||||
testFooBoxIsTrue("prefixIncReturnsCorrectValue.kt");
|
checkFooBoxIsTrue("prefixIncReturnsCorrectValue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testOverloadedCallOnProperty() throws Exception {
|
public void testOverloadedCallOnProperty() throws Exception {
|
||||||
testFooBoxIsTrue("overloadedCallOnProperty.kt");
|
checkFooBoxIsTrue("overloadedCallOnProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPostfixOnProperty() throws Exception {
|
public void testPostfixOnProperty() throws Exception {
|
||||||
testFooBoxIsTrue("postfixOnProperty.kt");
|
checkFooBoxIsTrue("postfixOnProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testOperatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception {
|
public void testOperatorOverloadOnPropertyCallGetterAndSetterOnlyOnce() throws Exception {
|
||||||
testFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt");
|
checkFooBoxIsTrue("operatorOverloadOnPropertyCallGetterAndSetterOnlyOnce.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testUnaryOnIntProperty() throws Exception {
|
public void testUnaryOnIntProperty() throws Exception {
|
||||||
testFooBoxIsTrue("unaryOnIntProperty.kt");
|
checkFooBoxIsTrue("unaryOnIntProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testUnaryOnIntPropertyAsStatement() throws Exception {
|
public void testUnaryOnIntPropertyAsStatement() throws Exception {
|
||||||
testFooBoxIsTrue("unaryOnIntProperty2.kt");
|
checkFooBoxIsTrue("unaryOnIntProperty2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testBinaryDivOverload() throws Exception {
|
public void testBinaryDivOverload() throws Exception {
|
||||||
testFooBoxIsTrue("binaryDivOverload.kt");
|
checkFooBoxIsTrue("binaryDivOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPlusAssignNoReassign() throws Exception {
|
public void testPlusAssignNoReassign() throws Exception {
|
||||||
testFooBoxIsTrue("plusAssignNoReassign.kt");
|
checkFooBoxIsTrue("plusAssignNoReassign.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNotOverload() throws Exception {
|
public void testNotOverload() throws Exception {
|
||||||
testFooBoxIsTrue("notOverload.kt");
|
checkFooBoxIsTrue("notOverload.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testCompareTo() throws Exception {
|
public void testCompareTo() throws Exception {
|
||||||
testFooBoxIsTrue("compareTo.kt");
|
checkFooBoxIsTrue("compareTo.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testPlusAndMinusAsAnExpression() throws Exception {
|
public void testPlusAndMinusAsAnExpression() throws Exception {
|
||||||
testFooBoxIsTrue("plusAndMinusAsAnExpression.kt");
|
checkFooBoxIsTrue("plusAndMinusAsAnExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testUsingModInCaseModAssignNotAvailable() throws Exception {
|
public void testUsingModInCaseModAssignNotAvailable() throws Exception {
|
||||||
testFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt");
|
checkFooBoxIsTrue("usingModInCaseModAssignNotAvailable.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOverloadPlusAssignArrayList() throws Exception {
|
public void testOverloadPlusAssignArrayList() throws Exception {
|
||||||
testFooBoxIsOk("overloadPlusAssignArrayList.kt");
|
checkFooBoxIsOk("overloadPlusAssignArrayList.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,37 +32,37 @@ public final class PatternMatchingTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testWhenType() throws Exception {
|
public void testWhenType() throws Exception {
|
||||||
testFooBoxIsTrue("whenType.kt");
|
checkFooBoxIsTrue("whenType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenNotType() throws Exception {
|
public void testWhenNotType() throws Exception {
|
||||||
testFooBoxIsTrue("whenNotType.kt");
|
checkFooBoxIsTrue("whenNotType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenExecutesOnlyOnce() throws Exception {
|
public void testWhenExecutesOnlyOnce() throws Exception {
|
||||||
testFooBoxIsTrue("whenExecutesOnlyOnce.kt");
|
checkFooBoxIsTrue("whenExecutesOnlyOnce.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenValue() throws Exception {
|
public void testWhenValue() throws Exception {
|
||||||
testFooBoxIsTrue("whenValue.kt");
|
checkFooBoxIsTrue("whenValue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenNotValue() throws Exception {
|
public void testWhenNotValue() throws Exception {
|
||||||
testFooBoxIsTrue("whenNotValue.kt");
|
checkFooBoxIsTrue("whenNotValue.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenValueOrType() throws Exception {
|
public void testWhenValueOrType() throws Exception {
|
||||||
testFooBoxIsTrue("whenValueOrType.kt");
|
checkFooBoxIsTrue("whenValueOrType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenWithIf() throws Exception {
|
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 {
|
public void testMatchNullableType() throws Exception {
|
||||||
testFooBoxIsTrue("matchNullableType.kt");
|
checkFooBoxIsTrue("matchNullableType.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testWhenAsExpression() throws Exception {
|
public void testWhenAsExpression() throws Exception {
|
||||||
testFooBoxIsTrue("whenAsExpression.kt");
|
checkFooBoxIsTrue("whenAsExpression.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void whenAsExpressionWithThrow() throws Exception {
|
public void whenAsExpressionWithThrow() throws Exception {
|
||||||
try {
|
try {
|
||||||
testFooBoxIsTrue("whenAsExpressionWithThrow.kt");
|
checkFooBoxIsTrue("whenAsExpressionWithThrow.kt");
|
||||||
fail();
|
fail();
|
||||||
} catch (JavaScriptException e) {
|
} catch (JavaScriptException e) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,12 +30,12 @@ public final class PropertyAccessTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testAccessToInstanceProperty() throws Exception {
|
public void testAccessToInstanceProperty() throws Exception {
|
||||||
testFooBoxIsTrue("accessToInstanceProperty.kt");
|
checkFooBoxIsTrue("accessToInstanceProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testTwoClassesWithProperties() throws Exception {
|
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 {
|
public void testCustomGetter() throws Exception {
|
||||||
testFooBoxIsTrue("customGetter.kt");
|
checkFooBoxIsTrue("customGetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testCustomSetter() throws Exception {
|
public void testCustomSetter() throws Exception {
|
||||||
testFooBoxIsTrue("customSetter.kt");
|
checkFooBoxIsTrue("customSetter.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSafeCall() throws Exception {
|
public void testSafeCall() throws Exception {
|
||||||
testFooBoxIsTrue("safeCall.kt");
|
checkFooBoxIsTrue("safeCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO: place safecalls under distinkt category
|
//TODO: place safecalls under distinkt category
|
||||||
public void testSafeCallReturnsNullIfFails() throws Exception {
|
public void testSafeCallReturnsNullIfFails() throws Exception {
|
||||||
testFooBoxIsTrue("safeCallReturnsNullIfFails.kt");
|
checkFooBoxIsTrue("safeCallReturnsNullIfFails.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testNamespacePropertyInitializer() throws Exception {
|
public void testNamespacePropertyInitializer() throws Exception {
|
||||||
testFooBoxIsTrue("namespacePropertyInitializer.kt");
|
checkFooBoxIsTrue("namespacePropertyInitializer.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testNamespacePropertySet() throws Exception {
|
public void testNamespacePropertySet() throws Exception {
|
||||||
testFooBoxIsTrue("namespacePropertySet.kt");
|
checkFooBoxIsTrue("namespacePropertySet.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNamespaceCustomAccessors() throws Exception {
|
public void testNamespaceCustomAccessors() throws Exception {
|
||||||
testFooBoxIsTrue("namespaceCustomAccessors.kt");
|
checkFooBoxIsTrue("namespaceCustomAccessors.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testClassUsesNamespaceProperties() throws Exception {
|
public void testClassUsesNamespaceProperties() throws Exception {
|
||||||
testFooBoxIsTrue("classUsesNamespaceProperties.kt");
|
checkFooBoxIsTrue("classUsesNamespaceProperties.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testSafeAccess() throws Exception {
|
public void testSafeAccess() throws Exception {
|
||||||
testFooBoxIsTrue("safeAccess.kt");
|
checkFooBoxIsTrue("safeAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testSafeExtensionFunctionCall() throws Exception {
|
public void testSafeExtensionFunctionCall() throws Exception {
|
||||||
testFooBoxIsOk("safeExtensionFunctionCall.kt");
|
checkFooBoxIsOk("safeExtensionFunctionCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtensionLiteralSafeCall() throws Exception {
|
public void testExtensionLiteralSafeCall() throws Exception {
|
||||||
testFooBoxIsTrue("extensionLiteralSafeCall.kt");
|
checkFooBoxIsTrue("extensionLiteralSafeCall.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,10 +29,10 @@ public class RTTITest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testIsSameClass() throws Exception {
|
public void testIsSameClass() throws Exception {
|
||||||
testFooBoxIsTrue("isSameClass.kt");
|
checkFooBoxIsTrue("isSameClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNotIsOtherClass() throws Exception {
|
public void testNotIsOtherClass() throws Exception {
|
||||||
testFooBoxIsTrue("notIsOtherClass.kt");
|
checkFooBoxIsTrue("notIsOtherClass.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,20 +30,20 @@ public final class RangeTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testExplicitRange() throws Exception {
|
public void testExplicitRange() throws Exception {
|
||||||
testFooBoxIsTrue("explicitRange.kt");
|
checkFooBoxIsTrue("explicitRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testRangeSugarSyntax() throws Exception {
|
public void testRangeSugarSyntax() throws Exception {
|
||||||
testFooBoxIsTrue("rangeSugarSyntax.kt");
|
checkFooBoxIsTrue("rangeSugarSyntax.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testIntInRange() throws Exception {
|
public void testIntInRange() throws Exception {
|
||||||
testFooBoxIsTrue("intInRange.kt");
|
checkFooBoxIsTrue("intInRange.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIteratingOverRanges() throws Exception {
|
public void testIteratingOverRanges() throws Exception {
|
||||||
testFooBoxIsTrue("iteratingOverRanges.kt");
|
checkFooBoxIsTrue("iteratingOverRanges.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public final class SimpleTestSuite extends UsefulTestCase {
|
|||||||
return Suite.suiteForDirectory("simple/", new Suite.SingleFileTester() {
|
return Suite.suiteForDirectory("simple/", new Suite.SingleFileTester() {
|
||||||
@Override
|
@Override
|
||||||
public void performTest(@NotNull Suite test, @NotNull String filename) throws Exception {
|
public void performTest(@NotNull Suite test, @NotNull String filename) throws Exception {
|
||||||
test.testFooBoxIsTrue(filename);
|
test.checkFooBoxIsTrue(filename);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,38 +29,38 @@ public class StandardClassesTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testArray() throws Exception {
|
public void testArray() throws Exception {
|
||||||
testFooBoxIsTrue("array.kt");
|
checkFooBoxIsTrue("array.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testArrayAccess() throws Exception {
|
public void testArrayAccess() throws Exception {
|
||||||
testFooBoxIsTrue("arrayAccess.kt");
|
checkFooBoxIsTrue("arrayAccess.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testArrayIsFilledWithNulls() throws Exception {
|
public void testArrayIsFilledWithNulls() throws Exception {
|
||||||
testFooBoxIsTrue("arrayIsFilledWithNulls.kt");
|
checkFooBoxIsTrue("arrayIsFilledWithNulls.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testArrayFunctionConstructor() throws Exception {
|
public void testArrayFunctionConstructor() throws Exception {
|
||||||
testFooBoxIsTrue("arrayFunctionConstructor.kt");
|
checkFooBoxIsTrue("arrayFunctionConstructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testArraySize() throws Exception {
|
public void testArraySize() throws Exception {
|
||||||
testFooBoxIsTrue("arraySize.kt");
|
checkFooBoxIsTrue("arraySize.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: this feature in not supported for some time
|
//TODO: this feature in not supported for some time
|
||||||
//TODO: support it. Probably configurable.
|
//TODO: support it. Probably configurable.
|
||||||
// (expected = JavaScriptException.class)
|
// (expected = JavaScriptException.class)
|
||||||
// public void arrayThrowsExceptionOnOOBaccess() throws Exception {
|
// public void arrayThrowsExceptionOnOOBaccess() throws Exception {
|
||||||
// testFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt");
|
// checkFooBoxIsTrue("arrayThrowsExceptionOnOOBaccess.kt");
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public void testArraysIterator() throws Exception {
|
public void testArraysIterator() throws Exception {
|
||||||
testFooBoxIsTrue("arraysIterator.kt");
|
checkFooBoxIsTrue("arraysIterator.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public class StringTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testStringConstant() throws Exception {
|
public void testStringConstant() throws Exception {
|
||||||
testFooBoxIsTrue("stringConstant.kt");
|
checkFooBoxIsTrue("stringConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStringAssignment() throws Exception {
|
public void testStringAssignment() throws Exception {
|
||||||
testFooBoxIsTrue("stringAssignment.kt");
|
checkFooBoxIsTrue("stringAssignment.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIntInTemplate() throws Exception {
|
public void testIntInTemplate() throws Exception {
|
||||||
@@ -49,6 +49,6 @@ public class StringTest extends AbstractExpressionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testToStringMethod() throws Exception {
|
public void testToStringMethod() throws Exception {
|
||||||
testFooBoxIsTrue("objectToStringCallInTemplate.kt");
|
checkFooBoxIsTrue("objectToStringCallInTemplate.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,41 +30,41 @@ public final class TraitTest extends TranslationTest {
|
|||||||
|
|
||||||
|
|
||||||
public void testTraitAddsFunctionsToClass() throws Exception {
|
public void testTraitAddsFunctionsToClass() throws Exception {
|
||||||
testFooBoxIsTrue("traitAddsFunctionsToClass.kt");
|
checkFooBoxIsTrue("traitAddsFunctionsToClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testClassDerivesFromClassAndTrait() throws Exception {
|
public void testClassDerivesFromClassAndTrait() throws Exception {
|
||||||
testFooBoxIsTrue("classDerivesFromClassAndTrait.kt");
|
checkFooBoxIsTrue("classDerivesFromClassAndTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testClassDerivesFromTraitAndClass() throws Exception {
|
public void testClassDerivesFromTraitAndClass() throws Exception {
|
||||||
testFooBoxIsTrue("classDerivesFromTraitAndClass.kt");
|
checkFooBoxIsTrue("classDerivesFromTraitAndClass.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testExample() throws Exception {
|
public void testExample() throws Exception {
|
||||||
testFooBoxIsTrue("example.kt");
|
checkFooBoxIsTrue("example.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testTraitExtendsTrait() throws Exception {
|
public void testTraitExtendsTrait() throws Exception {
|
||||||
testFooBoxIsTrue("traitExtendsTrait.kt");
|
checkFooBoxIsTrue("traitExtendsTrait.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testTraitExtendsTwoTraits() throws Exception {
|
public void testTraitExtendsTwoTraits() throws Exception {
|
||||||
testFooBoxIsTrue("traitExtendsTwoTraits.kt");
|
checkFooBoxIsTrue("traitExtendsTwoTraits.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testFunDelegation() throws Exception {
|
public void testFunDelegation() throws Exception {
|
||||||
testFooBoxIsOk("funDelegation.jet");
|
checkFooBoxIsOk("funDelegation.jet");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void testDefinitionOrder() throws Exception {
|
public void testDefinitionOrder() throws Exception {
|
||||||
testFooBoxIsTrue("definitionOrder.kt");
|
checkFooBoxIsTrue("definitionOrder.kt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.k2js.test;
|
package org.jetbrains.k2js.test;
|
||||||
|
|
||||||
import com.google.dart.compiler.backend.js.ast.JsProgram;
|
import com.google.dart.compiler.backend.js.ast.JsProgram;
|
||||||
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.k2js.facade.K2JSTranslator;
|
import org.jetbrains.k2js.facade.K2JSTranslator;
|
||||||
@@ -27,9 +28,6 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
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.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -158,13 +156,17 @@ public abstract class TranslationTest extends BaseTest {
|
|||||||
return getExpectedPath() + testName + ".out";
|
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);
|
FileReader reader = new FileReader(inputFile);
|
||||||
context.evaluateReader(scope, reader, inputFile, 1, null);
|
try {
|
||||||
reader.close();
|
context.evaluateReader(scope, reader, inputFile, 1, null);
|
||||||
|
} finally {
|
||||||
|
reader.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void runRhinoTest(List<String> fileNames, RhinoResultChecker checker) throws Exception {
|
protected static void runRhinoTest(@NotNull List<String> fileNames,
|
||||||
|
@NotNull RhinoResultChecker checker) throws Exception {
|
||||||
Context context = Context.enter();
|
Context context = Context.enter();
|
||||||
Scriptable scope = context.initStandardObjects();
|
Scriptable scope = context.initStandardObjects();
|
||||||
for (String filename : fileNames) {
|
for (String filename : fileNames) {
|
||||||
@@ -174,11 +176,11 @@ public abstract class TranslationTest extends BaseTest {
|
|||||||
Context.exit();
|
Context.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFooBoxIsTrue(String filename) throws Exception {
|
public void checkFooBoxIsTrue(String filename) throws Exception {
|
||||||
testFunctionOutput(filename, "foo", "box", true);
|
testFunctionOutput(filename, "foo", "box", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFooBoxIsOk(String filename) throws Exception {
|
public void checkFooBoxIsOk(String filename) throws Exception {
|
||||||
testFunctionOutput(filename, "foo", "box", "OK");
|
testFunctionOutput(filename, "foo", "box", "OK");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,21 +190,16 @@ public abstract class TranslationTest extends BaseTest {
|
|||||||
new RhinoSystemOutputChecker(expectedResult, Arrays.asList(args)));
|
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);
|
checkOutput(testName + ".kt", readFile(expected(testName + testId)), args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readFile(String path) throws IOException {
|
private static String readFile(String path) throws IOException {
|
||||||
FileInputStream stream = new FileInputStream(new File(path));
|
FileInputStream stream = new FileInputStream(new File(path));
|
||||||
try {
|
try {
|
||||||
FileChannel fc = stream.getChannel();
|
return FileUtil.loadTextAndClose(stream);
|
||||||
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();
|
|
||||||
} finally {
|
} finally {
|
||||||
stream.close();
|
stream.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ public final class TupleTest extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testTwoElements() throws Exception {
|
public void testTwoElements() throws Exception {
|
||||||
testFooBoxIsTrue("twoElements.kt");
|
checkFooBoxIsTrue("twoElements.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultipleMembers() throws Exception {
|
public void testMultipleMembers() throws Exception {
|
||||||
testFooBoxIsTrue("multipleMembers.kt");
|
checkFooBoxIsTrue("multipleMembers.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,22 +29,22 @@ public final class WebDemoExamples2Test extends TranslationTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testBottles() throws Exception {
|
public void testBottles() throws Exception {
|
||||||
testWithMain("bottles", "2", "2");
|
performTestWithMain("bottles", "2", "2");
|
||||||
testWithMain("bottles", "");
|
performTestWithMain("bottles", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testLife() throws Exception {
|
public void testLife() throws Exception {
|
||||||
testWithMain("life", "", "2");
|
performTestWithMain("life", "", "2");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testBuilder() throws Exception {
|
public void testBuilder() throws Exception {
|
||||||
testWithMain("builder", "");
|
performTestWithMain("builder", "");
|
||||||
testWithMain("builder", "1", "over9000");
|
performTestWithMain("builder", "1", "over9000");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: comparator LinkedList dependencies
|
//TODO: comparator LinkedList dependencies
|
||||||
// @Test
|
// @Test
|
||||||
// public void maze() throws Exception {
|
// public void maze() throws Exception {
|
||||||
// testWithMain("maze", "");
|
// performTestWithMain("maze", "");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,8 +61,11 @@ public final class K2JSTranslator {
|
|||||||
}
|
}
|
||||||
String callToMain = translator.generateCallToMain(fileWithMain, "");
|
String callToMain = translator.generateCallToMain(fileWithMain, "");
|
||||||
FileWriter writer = new FileWriter(new File(outputPath));
|
FileWriter writer = new FileWriter(new File(outputPath));
|
||||||
writer.write(programCode + callToMain);
|
try {
|
||||||
writer.close();
|
writer.write(programCode + callToMain);
|
||||||
|
} finally {
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void saveProgramToFile(@NotNull String outputFile, @NotNull JsProgram program) throws IOException {
|
public static void saveProgramToFile(@NotNull String outputFile, @NotNull JsProgram program) throws IOException {
|
||||||
@@ -79,6 +82,8 @@ public final class K2JSTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO: refactor
|
//TODO: refactor
|
||||||
|
//TODO: web demo related method
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
@NotNull
|
@NotNull
|
||||||
public String translateStringWithCallToMain(@NotNull String programText, @NotNull String argumentsString) {
|
public String translateStringWithCallToMain(@NotNull String programText, @NotNull String argumentsString) {
|
||||||
JetFile file = JetFileUtils.createPsiFile("test", programText, getProject());
|
JetFile file = JetFileUtils.createPsiFile("test", programText, getProject());
|
||||||
@@ -103,6 +108,8 @@ public final class K2JSTranslator {
|
|||||||
return generator.generateToString(program);
|
return generator.generateToString(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: relates to web demo
|
||||||
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
@NotNull
|
@NotNull
|
||||||
public BindingContext analyzeProgramCode(@NotNull String programText) {
|
public BindingContext analyzeProgramCode(@NotNull String programText) {
|
||||||
JetFile file = JetFileUtils.createPsiFile("test", programText, getProject());
|
JetFile file = JetFileUtils.createPsiFile("test", programText, getProject());
|
||||||
@@ -126,7 +133,7 @@ public final class K2JSTranslator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<String> parseString(@NotNull String argumentString) {
|
private static List<String> parseString(@NotNull String argumentString) {
|
||||||
List<String> result = new ArrayList<String>();
|
List<String> result = new ArrayList<String>();
|
||||||
StringTokenizer stringTokenizer = new StringTokenizer(argumentString);
|
StringTokenizer stringTokenizer = new StringTokenizer(argumentString);
|
||||||
while (stringTokenizer.hasMoreTokens()) {
|
while (stringTokenizer.hasMoreTokens()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user