diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java index 0fe8e1647d2..d88c8faaba7 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.js.test; import com.google.common.collect.Lists; import com.google.dart.compiler.backend.js.ast.JsNode; +import com.google.dart.compiler.backend.js.ast.JsProgram; import com.intellij.openapi.project.Project; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.vfs.StandardFileSystems; @@ -181,7 +182,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment { if (!(translationResult instanceof TranslationResult.Success)) return; TranslationResult.Success successResult = (TranslationResult.Success) translationResult; - getConsumer().consume(successResult.getProgram()); + processJsProgram(successResult.getProgram()); OutputFileCollection outputFiles = successResult.getOutputFiles(outputFile, getOutputPrefixFile(), getOutputPostfixFile()); File outputDir = outputFile.getParentFile(); @@ -205,10 +206,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment { return false; } - protected Consumer getConsumer() { - //noinspection unchecked - return Consumer.EMPTY_CONSUMER; - } + protected void processJsProgram(@NotNull JsProgram program) throws Exception { } protected void runRhinoTests( @NotNull String testName, diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/SingleFileTranslationWithDirectivesTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/SingleFileTranslationWithDirectivesTest.java index 9872292d34a..215f5b2216f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/SingleFileTranslationWithDirectivesTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/SingleFileTranslationWithDirectivesTest.java @@ -16,16 +16,12 @@ package org.jetbrains.kotlin.js.test; -import com.google.dart.compiler.backend.js.ast.JsNode; -import com.intellij.util.Consumer; +import com.google.dart.compiler.backend.js.ast.JsProgram; import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.js.test.utils.DirectiveTestUtils; import org.jetbrains.kotlin.js.test.utils.JsTestUtils; -import org.jetbrains.kotlin.js.test.utils.MemoizeConsumer; public abstract class SingleFileTranslationWithDirectivesTest extends SingleFileTranslationTest { - private final MemoizeConsumer nodeConsumer = new MemoizeConsumer(); - public SingleFileTranslationWithDirectivesTest(@NotNull String main) { super(main); } @@ -33,26 +29,12 @@ public abstract class SingleFileTranslationWithDirectivesTest extends SingleFile @Override public void setUp() throws Exception { super.setUp(); - nodeConsumer.consume(null); - } - - protected void checkFooBoxIsOkWithDirectives() throws Exception { - checkFooBoxIsOk(); - processDirectives(); - } - - protected void processDirectives() throws Exception { - String fileName = getInputFilePath(getTestName(true) + ".kt"); - String fileText = JsTestUtils.readFile(fileName); - - JsNode lastJsNode = nodeConsumer.getLastValue(); - assert lastJsNode != null; - - DirectiveTestUtils.processDirectives(lastJsNode, fileText); } @Override - protected Consumer getConsumer() { - return nodeConsumer; + protected void processJsProgram(@NotNull JsProgram program) throws Exception { + String fileName = getInputFilePath(getTestName(true) + ".kt"); + String fileText = JsTestUtils.readFile(fileName); + DirectiveTestUtils.processDirectives(program, fileText); } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineMultiFileTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineMultiFileTest.java index bead9a8660a..ffa0d1c0e82 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineMultiFileTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineMultiFileTest.java @@ -16,20 +16,17 @@ package org.jetbrains.kotlin.js.test.semantics; -import com.google.dart.compiler.backend.js.ast.JsNode; -import com.intellij.util.Consumer; +import com.google.dart.compiler.backend.js.ast.JsProgram; +import org.jetbrains.annotations.NotNull; import org.jetbrains.kotlin.js.test.MultipleFilesTranslationTest; import org.jetbrains.kotlin.js.test.utils.DirectiveTestUtils; import org.jetbrains.kotlin.js.test.utils.JsTestUtils; -import org.jetbrains.kotlin.js.test.utils.MemoizeConsumer; import java.util.List; import static org.jetbrains.kotlin.js.test.utils.JsTestUtils.getAllFilesInDir; public final class InlineMultiFileTest extends MultipleFilesTranslationTest { - private final MemoizeConsumer nodeConsumer = new MemoizeConsumer(); - public InlineMultiFileTest() { super("inlineMultiFile/"); } @@ -37,12 +34,10 @@ public final class InlineMultiFileTest extends MultipleFilesTranslationTest { @Override public void setUp() throws Exception { super.setUp(); - nodeConsumer.consume(null); } public void testInlineMultiFileSimple() throws Exception { checkFooBoxIsOk(); - processInlineDirectives(); } public void testBuilders() throws Exception { @@ -71,7 +66,6 @@ public final class InlineMultiFileTest extends MultipleFilesTranslationTest { public void testTrait() throws Exception { checkFooBoxIsOk(); - processInlineDirectives(); } public void testUse() throws Exception { @@ -154,23 +148,14 @@ public final class InlineMultiFileTest extends MultipleFilesTranslationTest { checkFooBoxIsOk(); } - private void processInlineDirectives() throws Exception { + @Override + protected void processJsProgram(@NotNull JsProgram program) throws Exception { String dir = getTestName(true); List fileNames = getAllFilesInDir(getInputFilePath(dir)); for (String fileName : fileNames) { String fileText = JsTestUtils.readFile(fileName); - - JsNode lastJsNode = nodeConsumer.getLastValue(); - assert lastJsNode != null; - - DirectiveTestUtils.processDirectives(lastJsNode, fileText); + DirectiveTestUtils.processDirectives(program, fileText); } } - - @Override - protected Consumer getConsumer() { - return nodeConsumer; - } - } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineTest.java index cf2fdbb90b6..b08d39e34ad 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/InlineTest.java @@ -25,140 +25,140 @@ public final class InlineTest extends SingleFileTranslationWithDirectivesTest { } public void testInlineSimpleAssignment() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineGenericSimple() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineIntSimple() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineInc() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineCallNoInline() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineFunctionInLambda() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineLambdaNoCapture() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineLambdaWithCapture() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineChain() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineChainWithFewStatements() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testCallInlineFunctionOnTopLevelSimple() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testCallInlineFunctionOnTopLevel() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineIf() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineNoReturn() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testStatementsAfterReturn() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLambdaReassignment() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLambdaReassignmentWithCapture() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineMethod() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testThisImplicitlyCaptured() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testAstCopy() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testNoInlineLambda() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testlambdaInLambda() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testInlineDefaultArgument() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineFunction() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineFunctionDeclaredInLambda() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineExtensionFunction() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineFunctionNameClash() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineFunctionComplex() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testArrayLiteralAliasing() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLocalInlineFunctionReference() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testThisLiteralAliasing() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testIdentityEquals() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testVararg() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testMutualRecursion() throws Exception { try { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } catch (InlineRecursionException e) { return; } @@ -167,74 +167,74 @@ public final class InlineTest extends SingleFileTranslationWithDirectivesTest { } public void testInlineOrder() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testCallableReference() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testCallableReferenceOfLocalInline() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testAnonymousObjectInlineMethod() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testClassObject() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testExtension() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testExtensionWithManyArguments() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testParams() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testRootConstructor() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSeveralClosures() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSeveralUsage() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleDouble() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleInt() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleEnum() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleLambda() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleObject() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testIncrementProperty() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleReturnFunctionWithResultUnused() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodeTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodeTest.java index d14f07245d1..66d5ce24f2f 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodeTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodeTest.java @@ -85,11 +85,11 @@ public final class JsCodeTest extends SingleFileTranslationWithDirectivesTest { } public void testLabelSiblingClash() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLabelNestedClash() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testTryCatchFinally() throws Exception { diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/LabelTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/LabelTest.java index 94e8adf0327..b708e39b37c 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/LabelTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/LabelTest.java @@ -24,38 +24,38 @@ public class LabelTest extends SingleFileTranslationWithDirectivesTest { } public void testSimpleLabel() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSiblingLabels() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testNestedLabels() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSimpleLabelInlined() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSiblingLabelsInlined() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testSiblingLabelsInlinedClashing() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testNestedLabelsInlinedClashing() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testLabelWithVariableClashing() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } public void testNestedLabelsInlinedClashingAtFunctionsWithClosure() throws Exception { - checkFooBoxIsOkWithDirectives(); + checkFooBoxIsOk(); } } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/MemoizeConsumer.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/MemoizeConsumer.kt deleted file mode 100644 index 825778d587b..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/utils/MemoizeConsumer.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.js.test.utils - -import com.intellij.util.Consumer - -class MemoizeConsumer : Consumer { - var lastValue: T? = null - - override fun consume(value: T?) { - lastValue = value - } -}