JS test: added inline tests
This commit is contained in:
committed by
Zalim Bashorov
parent
987708680f
commit
3f2d4b31be
@@ -55,5 +55,10 @@ public abstract class MultipleFilesTranslationTest extends BasicTest {
|
||||
public void checkFooBoxIsTrue(@NotNull String dirName) throws Exception {
|
||||
runMultiFileTest(dirName, TEST_PACKAGE, TEST_FUNCTION, true);
|
||||
}
|
||||
|
||||
public void checkFooBoxIsOk() throws Exception {
|
||||
String dir = getTestName(true);
|
||||
runMultiFileTest(dir, TEST_PACKAGE, TEST_FUNCTION, "OK");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright 2010-2014 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.k2js.test.semantics;
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.JsNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.config.Config;
|
||||
import org.jetbrains.k2js.facade.MainCallParameters;
|
||||
import org.jetbrains.k2js.test.MultipleFilesTranslationTest;
|
||||
import org.jetbrains.k2js.test.utils.InlineTestUtils;
|
||||
import org.jetbrains.k2js.test.utils.JsTestUtils;
|
||||
import org.jetbrains.k2js.test.utils.TranslationUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.k2js.test.utils.JsTestUtils.getAllFilesInDir;
|
||||
|
||||
public final class InlineMultiFileTest extends MultipleFilesTranslationTest {
|
||||
private JsNode lastJsNode;
|
||||
|
||||
public InlineMultiFileTest() {
|
||||
super("inlineMultiFile/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
lastJsNode = null;
|
||||
}
|
||||
|
||||
public void testInlineMultiFileSimple() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
processInlineDirectives();
|
||||
}
|
||||
|
||||
public void testBuilders() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testBuildersAndLambdaCapturing() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAnonymousObjectOnCallSite() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAnonymousObjectOnCallSiteSuperParams() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAnonymousObjectOnDeclarationSite() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testAnonymousObjectOnDeclarationSiteSuperParams() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testTrait() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
processInlineDirectives();
|
||||
}
|
||||
|
||||
public void testUse() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testWith() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testTryCatch() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testTryCatch2() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testTryCatchFinally() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testLambdaCloning() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testLambdaInLambda2() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testLambdaInLambdaNoInline() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testRegeneratedLambdaName() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testSameCaptured() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testClosureChain() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testInlineInDefaultParameter() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testDefaultMethod() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testSimpleDefaultMethod() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCaptureInlinable() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCaptureInlinableAndOther() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testCaptureThisAndReceiver() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testGenerics() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testSimpleCapturingInClass() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
public void testSimpleCapturingInPackage() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void translateFiles(
|
||||
@NotNull List<JetFile> jetFiles,
|
||||
@NotNull File outputFile,
|
||||
@NotNull MainCallParameters mainCallParameters,
|
||||
@NotNull Config config
|
||||
) throws Exception {
|
||||
lastJsNode = TranslationUtils.translateFilesAndGetAst(mainCallParameters, jetFiles, outputFile, null, null, config);
|
||||
}
|
||||
|
||||
private void processInlineDirectives() throws Exception {
|
||||
String dir = getTestName(true);
|
||||
List<String> fileNames = getAllFilesInDir(getInputFilePath(dir));
|
||||
|
||||
for (String fileName : fileNames) {
|
||||
String fileText = JsTestUtils.readFile(fileName);
|
||||
InlineTestUtils.processDirectives(lastJsNode, fileText);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,262 @@
|
||||
|
||||
package org.jetbrains.k2js.test.semantics;
|
||||
|
||||
import com.google.dart.compiler.backend.js.ast.JsNode;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.k2js.config.Config;
|
||||
import org.jetbrains.k2js.facade.MainCallParameters;
|
||||
import org.jetbrains.k2js.inline.exception.InlineRecursionException;
|
||||
import org.jetbrains.k2js.test.SingleFileTranslationTest;
|
||||
import org.jetbrains.k2js.test.utils.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
public final class InlineTest extends SingleFileTranslationTest {
|
||||
private JsNode lastJsNode;
|
||||
|
||||
public InlineTest() {
|
||||
super("inline/");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
lastJsNode = null;
|
||||
}
|
||||
|
||||
public void testInlineSimpleAssignment() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineGenericSimple() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineIntSimple() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineInc() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineCallNoInline() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineFunctionInLambda() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineLambdaNoCapture() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineLambdaWithCapture() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineChain() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineChainWithFewStatements() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testCallInlineFunctionOnTopLevelSimple() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testCallInlineFunctionOnTopLevel() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineIf() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineNoReturn() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testStatementsAfterReturn() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLambdaReassignment() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLambdaReassignmentWithCapture() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineMethod() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testThisImplicitlyCaptured() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testAstCopy() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testNoInlineLambda() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testlambdaInLambda() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testInlineDefaultArgument() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineFunction() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineFunctionDeclaredInLambda() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineExtensionFunction() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineFunctionNameClash() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineFunctionComplex() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testArrayLiteralAliasing() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLocalInlineFunctionReference() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testThisLiteralAliasing() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testIdentityEquals() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testVararg() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testMutualRecursion() throws Exception {
|
||||
try {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
} catch (Exception e) {
|
||||
assert e.getCause() instanceof InlineRecursionException;
|
||||
}
|
||||
}
|
||||
|
||||
public void testInlineOrder() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testCallableReference() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testCallableReferenceOfLocalInline() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testAnonymousObjectInlineMethod() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testLabelNameClashing() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testClassObject() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testExtension() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testExtensionWithManyArguments() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testParams() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testRootConstructor() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSeveralClosures() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSeveralUsage() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSimpleDouble() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSimpleInt() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSimpleEnum() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSimpleLambda() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testSimpleObject() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
public void testIncrementProperty() throws Exception {
|
||||
checkFooBoxIsOkWithInlineDirectives();
|
||||
}
|
||||
|
||||
private void checkFooBoxIsOkWithInlineDirectives() throws Exception {
|
||||
checkFooBoxIsOk();
|
||||
processInlineDirectives();
|
||||
}
|
||||
|
||||
private void processInlineDirectives() throws Exception {
|
||||
String fileName = getInputFilePath(getTestName(true) + ".kt");
|
||||
String fileText = JsTestUtils.readFile(fileName);
|
||||
|
||||
InlineTestUtils.processDirectives(lastJsNode, fileText);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void translateFiles(
|
||||
@NotNull List<JetFile> jetFiles,
|
||||
@NotNull File outputFile,
|
||||
@NotNull MainCallParameters mainCallParameters,
|
||||
@NotNull Config config
|
||||
) throws Exception {
|
||||
lastJsNode = TranslationUtils.translateFilesAndGetAst(mainCallParameters, jetFiles, outputFile, null, null, config);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user