JS: removed AstConsumer from tests
This commit is contained in:
@@ -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<JsNode> getConsumer() {
|
||||
//noinspection unchecked
|
||||
return Consumer.EMPTY_CONSUMER;
|
||||
}
|
||||
protected void processJsProgram(@NotNull JsProgram program) throws Exception { }
|
||||
|
||||
protected void runRhinoTests(
|
||||
@NotNull String testName,
|
||||
|
||||
+5
-23
@@ -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<JsNode> nodeConsumer = new MemoizeConsumer<JsNode>();
|
||||
|
||||
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<JsNode> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<JsNode> nodeConsumer = new MemoizeConsumer<JsNode>();
|
||||
|
||||
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<String> 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<JsNode> getConsumer() {
|
||||
return nodeConsumer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<T : Any> : Consumer<T> {
|
||||
var lastValue: T? = null
|
||||
|
||||
override fun consume(value: T?) {
|
||||
lastValue = value
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user