From 0bff406a124a625ff59dc5c7c44352c5b991a381 Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Tue, 1 Sep 2020 12:04:15 +0300 Subject: [PATCH] [JS IR] Add infra to test compilation with error - add bunch of tests - fix help test --- compiler/testData/cli/js/jsExtraHelp.out | 1 + .../boxError/semantic/castToErrorType.kt | 16 +++ .../boxError/semantic/catchErrorType.kt | 24 ++++ .../boxError/semantic/evaluationOrder.kt | 31 +++++ .../semantic/mismatchTypeParameters.kt | 19 +++ .../codegen/boxError/semantic/missedBody.kt | 17 +++ .../boxError/semantic/reifiedNonInline.kt | 23 ++++ .../codegen/boxError/semantic/typeMismatch.kt | 22 ++++ .../boxError/semantic/unmatchedArguments.kt | 31 +++++ .../semantic/unresolvedFunctionReferece.kt | 17 +++ .../codegen/boxError/syntax/arrowReference.kt | 16 +++ .../boxError/syntax/evaluationOrder.kt | 33 +++++ .../boxError/syntax/incorectLexicalName.kt | 38 ++++++ .../codegen/boxError/syntax/missedArgument.kt | 20 +++ .../ir/irText/errors/unresolvedReference.txt | 8 +- .../generators/tests/GenerateJsTests.kt | 4 + .../jetbrains/kotlin/js/test/BasicBoxTest.kt | 26 ++-- .../IrJsCodegenBoxErrorTestGenerated.java | 122 ++++++++++++++++++ .../abstractClassesForGeneratedIrTests.kt | 5 + 19 files changed, 460 insertions(+), 13 deletions(-) create mode 100644 compiler/testData/codegen/boxError/semantic/castToErrorType.kt create mode 100644 compiler/testData/codegen/boxError/semantic/catchErrorType.kt create mode 100644 compiler/testData/codegen/boxError/semantic/evaluationOrder.kt create mode 100644 compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt create mode 100644 compiler/testData/codegen/boxError/semantic/missedBody.kt create mode 100644 compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt create mode 100644 compiler/testData/codegen/boxError/semantic/typeMismatch.kt create mode 100644 compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt create mode 100644 compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt create mode 100644 compiler/testData/codegen/boxError/syntax/arrowReference.kt create mode 100644 compiler/testData/codegen/boxError/syntax/evaluationOrder.kt create mode 100644 compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt create mode 100644 compiler/testData/codegen/boxError/syntax/missedArgument.kt create mode 100644 js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxErrorTestGenerated.java diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index 14d2f4cdcae..f3af3090898 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -3,6 +3,7 @@ where advanced options include: -Xdisable-fake-override-validator Disable IR fake override validator -Xenable-js-scripting Enable experimental support of .kts files using K/JS (with -Xir only) + -Xerror-tolerance-policy Set up error tolerance policy (NONE, SEMANTIC, SYNTAX, ALL) -Xfriend-modules= Paths to friend modules -Xfriend-modules-disabled Disable internal declaration export -Xgenerate-dts Generate TypeScript declarations .d.ts file alongside JS file. Available in IR backend only. diff --git a/compiler/testData/codegen/boxError/semantic/castToErrorType.kt b/compiler/testData/codegen/boxError/semantic/castToErrorType.kt new file mode 100644 index 00000000000..475d533faf2 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/castToErrorType.kt @@ -0,0 +1,16 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +fun foo(o: Any): Any = o as ErrType + +// FILE: b.kt + +fun box(): String { + try { + foo(Any()) + } catch (e: IllegalStateException) { + return "OK" + } + return "fail" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/catchErrorType.kt b/compiler/testData/codegen/boxError/semantic/catchErrorType.kt new file mode 100644 index 00000000000..1d1dd374393 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/catchErrorType.kt @@ -0,0 +1,24 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +fun bar() { throw Exception("..") } + +fun foo(): String { + try { + bar() + } catch (e: ErrType) { + throw Expception(e) + } +} + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return "OK" + } + return "fail" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/evaluationOrder.kt b/compiler/testData/codegen/boxError/semantic/evaluationOrder.kt new file mode 100644 index 00000000000..4fed0ff73fd --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/evaluationOrder.kt @@ -0,0 +1,31 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + + +fun bar(aa: Any, bb: Any, cc: Any) { +} + +fun foo() { + qux(a(), b(), c()) + beer() + f() +} + +fun a(): Any { storage += "a"; return storage } +fun b(): Any { storage += "b"; return storage } +fun c(): Any { storage += "c"; return storage } +fun f(): Any { storage += "FAIL"; return storage } + +var storage = "" + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return if (storage == "abc") "OK" else "FAIL ABC" + return "FAIL" + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt b/compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt new file mode 100644 index 00000000000..89bc1e0c572 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt @@ -0,0 +1,19 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +fun bar(a: T): T = a + +var storage = "" + +fun foo() { + storage += bar("O") + storage += bar("K") +} + +// FILE: b.kt + +fun box(): String { + foo() + return storage +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/missedBody.kt b/compiler/testData/codegen/boxError/semantic/missedBody.kt new file mode 100644 index 00000000000..13cf84aa8c1 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/missedBody.kt @@ -0,0 +1,17 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +fun bar(a: String, b: String): String + +fun foo(): String { + return bar("O", "K") +} + +// FILE: b.kt + +fun box(): String { + val r = foo() + if (r is String) return r + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt b/compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt new file mode 100644 index 00000000000..d97ccd28bec --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt @@ -0,0 +1,23 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +fun bar(t: T) = t + +fun qux() = T::class + +fun foo(): String { + return bar("OK") +} + +fun dec() { qux() } + +// FILE: b.kt + +fun box(): String { + try { + dec() + } catch (e: Throwable /*js ReferenceError*/) { + return foo() + } +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/typeMismatch.kt b/compiler/testData/codegen/boxError/semantic/typeMismatch.kt new file mode 100644 index 00000000000..8c3cb3e0141 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/typeMismatch.kt @@ -0,0 +1,22 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +class A +class B + +fun bar(): B = B() +fun foo(): A { + return bar() +} + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: ClassCastException) { + return "OK" + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt b/compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt new file mode 100644 index 00000000000..6ebed745f83 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt @@ -0,0 +1,31 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + +var storage = "" + +fun bar(a: String, b: String) { storage += a; storage += b; } + +fun foo1() { + bar("O", "K") + bar("FAIL1") +} + +fun foo2() { + bar("FAIL2", "FAIL2", "FAIL2", "FAIL2") +} + +// FILE: b.kt + +fun box(): String { + try { + foo1() + } catch (e: IllegalStateException) { + try { + foo2() + } catch (e: IllegalStateException) { + return storage + } + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt b/compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt new file mode 100644 index 00000000000..b22b6e3b7e0 --- /dev/null +++ b/compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt @@ -0,0 +1,17 @@ +// ERROR_POLICY: SEMANTIC + +// FILE: t.kt + + +fun foo() { bar() } + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return "OK" + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/syntax/arrowReference.kt b/compiler/testData/codegen/boxError/syntax/arrowReference.kt new file mode 100644 index 00000000000..b8879fbf9ee --- /dev/null +++ b/compiler/testData/codegen/boxError/syntax/arrowReference.kt @@ -0,0 +1,16 @@ +// ERROR_POLICY: SYNTAX + +// FILE: t.kt + +fun foo() { this->bar() } + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return "OK" + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/syntax/evaluationOrder.kt b/compiler/testData/codegen/boxError/syntax/evaluationOrder.kt new file mode 100644 index 00000000000..c5af952149a --- /dev/null +++ b/compiler/testData/codegen/boxError/syntax/evaluationOrder.kt @@ -0,0 +1,33 @@ +// ERROR_POLICY: SYNTAX + +// FILE: t.kt + + +fun bar(aa: Any, bb: Any, cc: Any) { + <<;;;;; + d8as9d89as + ??????? ====---- +} + +fun foo() { + bar(a(), b(), c()) + <<<<<,,,,>>>>> + f() +} + +fun a(): Any { storage += "a"; return storage } +fun b(): Any { storage += "b"; return storage } +fun c(): Any { storage += "c"; return storage } +fun f(): Any { storage += "FAIL"; return storage } + +var storage = "" + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return if (storage == "abc") "OK" else "FAIL ABC" + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt b/compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt new file mode 100644 index 00000000000..eec8af81fe1 --- /dev/null +++ b/compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt @@ -0,0 +1,38 @@ +// ERROR_POLICY: SYNTAX + +// FILE: t.kt + + +384jfjfj2934829...:::%:ББББ + +fun 124gga() {} + +val 481gu: Boolean = true + +var 981llj): Int = 42 + +// just check if it is compiled +class **jhghssk + +fun foo() { 124gga() } +fun bar() { return 481gu } +fun qux() { 981llj) = 481 } + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + try { + bar() + } catch (e: IllegalStateException) { + try { + qux() + } catch (e: IllegalStateException) { + return "OK" + } + } + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/codegen/boxError/syntax/missedArgument.kt b/compiler/testData/codegen/boxError/syntax/missedArgument.kt new file mode 100644 index 00000000000..51f22efc64d --- /dev/null +++ b/compiler/testData/codegen/boxError/syntax/missedArgument.kt @@ -0,0 +1,20 @@ +// ERROR_POLICY: SYNTAX + +// FILE: t.kt + +1sdasf + +fun bar() {} + +fun foo() { bar(,,,,,,,) } + +// FILE: b.kt + +fun box(): String { + try { + foo() + } catch (e: IllegalStateException) { + return "OK" + } + return "FAIL" +} \ No newline at end of file diff --git a/compiler/testData/ir/irText/errors/unresolvedReference.txt b/compiler/testData/ir/irText/errors/unresolvedReference.txt index acd1660f01f..cf5d57acaae 100644 --- a/compiler/testData/ir/irText/errors/unresolvedReference.txt +++ b/compiler/testData/ir/irText/errors/unresolvedReference.txt @@ -2,7 +2,7 @@ FILE fqName: fileName:/unresolvedReference.kt PROPERTY name:test1 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test1 type:IrErrorType visibility:private [final,static] EXPRESSION_BODY - ERROR_CALL '' type=IrErrorType + ERROR_CALL 'unresolved' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test1 visibility:public modality:FINAL [val] BLOCK_BODY @@ -11,7 +11,7 @@ FILE fqName: fileName:/unresolvedReference.kt PROPERTY name:test2 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test2 type:IrErrorType visibility:private [final,static] EXPRESSION_BODY - ERROR_CALL '' type=IrErrorType + ERROR_CALL 'unresolved()' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test2 visibility:public modality:FINAL [val] BLOCK_BODY @@ -20,7 +20,7 @@ FILE fqName: fileName:/unresolvedReference.kt PROPERTY name:test3 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test3 type:IrErrorType visibility:private [final,static] EXPRESSION_BODY - ERROR_CALL '' type=IrErrorType + ERROR_CALL 'unresolved(56)' type=IrErrorType receiver: CONST Int type=kotlin.Int value=42 CONST Int type=kotlin.Int value=56 FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType @@ -31,7 +31,7 @@ FILE fqName: fileName:/unresolvedReference.kt PROPERTY name:test4 visibility:public modality:FINAL [val] FIELD PROPERTY_BACKING_FIELD name:test4 type:IrErrorType visibility:private [final,static] EXPRESSION_BODY - ERROR_EXPR '' type=IrErrorType + ERROR_EXPR '42 *' type=IrErrorType FUN DEFAULT_PROPERTY_ACCESSOR name: visibility:public modality:FINAL <> () returnType:IrErrorType correspondingProperty: PROPERTY name:test4 visibility:public modality:FINAL [val] BLOCK_BODY diff --git a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt index fd9d1653dab..e489e6be078 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/generators/tests/GenerateJsTests.kt @@ -81,6 +81,10 @@ fun main(args: Array) { model("codegen/box", targetBackend = TargetBackend.JS_IR) } + testClass { + model("codegen/boxError", targetBackend = TargetBackend.JS_IR) + } + testClass { model("codegen/box", targetBackend = TargetBackend.JS_IR_ES6) } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt index 6f429c8e4d7..2b9d852f8c0 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicBoxTest.kt @@ -28,10 +28,7 @@ import org.jetbrains.kotlin.incremental.js.TranslationResultValue import org.jetbrains.kotlin.js.JavaScript import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor import org.jetbrains.kotlin.js.backend.ast.* -import org.jetbrains.kotlin.js.config.EcmaVersion -import org.jetbrains.kotlin.js.config.JSConfigurationKeys -import org.jetbrains.kotlin.js.config.JsConfig -import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding +import org.jetbrains.kotlin.js.config.* import org.jetbrains.kotlin.js.dce.DeadCodeElimination import org.jetbrains.kotlin.js.dce.InputFile import org.jetbrains.kotlin.js.dce.InputResource @@ -127,6 +124,9 @@ abstract class BasicBoxTest( val runPlainBoxFunction = RUN_PLAIN_BOX_FUNCTION.matcher(fileContent).find() val inferMainModule = INFER_MAIN_MODULE.matcher(fileContent).find() val expectActualLinker = EXPECT_ACTUAL_LINKER.matcher(fileContent).find() + val errorPolicyMatcher = ERROR_POLICY_PATTERN.matcher(fileContent) + val errorPolicy = + if (errorPolicyMatcher.find()) ErrorTolerancePolicy.resolvePolicy(errorPolicyMatcher.group(1)) else ErrorTolerancePolicy.DEFAULT val skipDceDriven = SKIP_DCE_DRIVEN.matcher(fileContent).find() val splitPerModule = SPLIT_PER_MODULE.matcher(fileContent).find() @@ -174,7 +174,7 @@ abstract class BasicBoxTest( testFactory.tmpDir, file.parent, module, outputFileName, dceOutputFileName, pirOutputFileName, dependencies, allDependencies, friends, modules.size > 1, !SKIP_SOURCEMAP_REMAPPING.matcher(fileContent).find(), outputPrefixFile, outputPostfixFile, - actualMainCallParameters, testPackage, testFunction, needsFullIrRuntime, isMainModule, expectActualLinker, skipDceDriven, splitPerModule + actualMainCallParameters, testPackage, testFunction, needsFullIrRuntime, isMainModule, expectActualLinker, skipDceDriven, splitPerModule, errorPolicy ) when { @@ -397,7 +397,8 @@ abstract class BasicBoxTest( isMainModule: Boolean, expectActualLinker: Boolean, skipDceDriven: Boolean, - splitPerModule: Boolean + splitPerModule: Boolean, + errorIgnorancePolicy: ErrorTolerancePolicy ) { val kotlinFiles = module.files.filter { it.fileName.endsWith(".kt") } val testFiles = kotlinFiles.map { it.fileName } @@ -413,7 +414,7 @@ abstract class BasicBoxTest( val psiFiles = createPsiFiles(allSourceFiles.sortedBy { it.canonicalPath }.map { it.canonicalPath }) val sourceDirs = (testFiles + additionalFiles).map { File(it).parent }.distinct() - val config = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData = null, expectActualLinker = expectActualLinker) + val config = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData = null, expectActualLinker = expectActualLinker, errorIgnorancePolicy) val outputFile = File(outputFileName) val dceOutputFile = File(dceOutputFileName) val pirOutputFile = File(pirOutputFileName) @@ -468,7 +469,7 @@ abstract class BasicBoxTest( .sortedBy { it.canonicalPath } .map { sourceToTranslationUnit[it]!! } - val recompiledConfig = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData, expectActualLinker) + val recompiledConfig = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData, expectActualLinker, ErrorTolerancePolicy.DEFAULT) val recompiledOutputFile = File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js") translateFiles( @@ -684,7 +685,7 @@ abstract class BasicBoxTest( private fun createConfig( sourceDirs: List, module: TestModule, dependencies: List, allDependencies: List, friends: List, - multiModule: Boolean, tmpDir: File, incrementalData: IncrementalData?, expectActualLinker: Boolean + multiModule: Boolean, tmpDir: File, incrementalData: IncrementalData?, expectActualLinker: Boolean, errorIgnorancePolicy: ErrorTolerancePolicy ): JsConfig { val configuration = environment.configuration.copy() @@ -707,6 +708,11 @@ abstract class BasicBoxTest( configuration.put(CommonConfigurationKeys.MODULE_NAME, module.name.removeSuffix(OLD_MODULE_SUFFIX)) configuration.put(JSConfigurationKeys.MODULE_KIND, module.moduleKind) configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.v5) + configuration.put(JSConfigurationKeys.ERROR_TOLERANCE_POLICY, errorIgnorancePolicy) + + if (errorIgnorancePolicy.allowErrors) { + configuration.put(JSConfigurationKeys.DEVELOPER_MODE, true) + } val hasFilesToRecompile = module.hasFilesToRecompile configuration.put(JSConfigurationKeys.META_INFO, multiModule) @@ -934,6 +940,8 @@ abstract class BasicBoxTest( private val SKIP_DCE_DRIVEN = Pattern.compile("^// *SKIP_DCE_DRIVEN *$", Pattern.MULTILINE) private val SPLIT_PER_MODULE = Pattern.compile("^// *SPLIT_PER_MODULE *$", Pattern.MULTILINE) + private val ERROR_POLICY_PATTERN = Pattern.compile("^// *ERROR_POLICY: *(.+)$", Pattern.MULTILINE) + @JvmStatic protected val runTestInNashorn = getBoolean("kotlin.js.useNashorn") diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxErrorTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxErrorTestGenerated.java new file mode 100644 index 00000000000..3b4c3b5c8c2 --- /dev/null +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxErrorTestGenerated.java @@ -0,0 +1,122 @@ +/* + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.js.test.ir.semantics; + +import com.intellij.testFramework.TestDataPath; +import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; +import org.jetbrains.kotlin.test.KotlinTestUtils; +import org.jetbrains.kotlin.test.TargetBackend; +import org.jetbrains.kotlin.test.TestMetadata; +import org.junit.runner.RunWith; + +import java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/boxError") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IrJsCodegenBoxErrorTestGenerated extends AbstractIrJsCodegenBoxErrorTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInBoxError() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("compiler/testData/codegen/boxError/semantic") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Semantic extends AbstractIrJsCodegenBoxErrorTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInSemantic() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/semantic"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("castToErrorType.kt") + public void testCastToErrorType() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/castToErrorType.kt"); + } + + @TestMetadata("catchErrorType.kt") + public void testCatchErrorType() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/catchErrorType.kt"); + } + + @TestMetadata("evaluationOrder.kt") + public void testEvaluationOrder() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/evaluationOrder.kt"); + } + + @TestMetadata("mismatchTypeParameters.kt") + public void testMismatchTypeParameters() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/mismatchTypeParameters.kt"); + } + + @TestMetadata("missedBody.kt") + public void testMissedBody() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/missedBody.kt"); + } + + @TestMetadata("reifiedNonInline.kt") + public void testReifiedNonInline() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/reifiedNonInline.kt"); + } + + @TestMetadata("typeMismatch.kt") + public void testTypeMismatch() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/typeMismatch.kt"); + } + + @TestMetadata("unmatchedArguments.kt") + public void testUnmatchedArguments() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/unmatchedArguments.kt"); + } + + @TestMetadata("unresolvedFunctionReferece.kt") + public void testUnresolvedFunctionReferece() throws Exception { + runTest("compiler/testData/codegen/boxError/semantic/unresolvedFunctionReferece.kt"); + } + } + + @TestMetadata("compiler/testData/codegen/boxError/syntax") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Syntax extends AbstractIrJsCodegenBoxErrorTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInSyntax() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/boxError/syntax"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @TestMetadata("arrowReference.kt") + public void testArrowReference() throws Exception { + runTest("compiler/testData/codegen/boxError/syntax/arrowReference.kt"); + } + + @TestMetadata("evaluationOrder.kt") + public void testEvaluationOrder() throws Exception { + runTest("compiler/testData/codegen/boxError/syntax/evaluationOrder.kt"); + } + + @TestMetadata("incorectLexicalName.kt") + public void testIncorectLexicalName() throws Exception { + runTest("compiler/testData/codegen/boxError/syntax/incorectLexicalName.kt"); + } + + @TestMetadata("missedArgument.kt") + public void testMissedArgument() throws Exception { + runTest("compiler/testData/codegen/boxError/syntax/missedArgument.kt"); + } + } +} diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt index 41cfd905237..0c1fb92b0f5 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/abstractClassesForGeneratedIrTests.kt @@ -14,6 +14,11 @@ abstract class AbstractIrJsCodegenBoxTest : BasicIrBoxTest( "codegen/irBox/" ) +abstract class AbstractIrJsCodegenBoxErrorTest : BasicIrBoxTest( + "compiler/testData/codegen/boxError/", + "codegen/irBoxError/" +) + abstract class AbstractIrWasmBoxJsTest : BasicIrBoxTest( TEST_DATA_DIR_PATH + "wasmBox/", "irWasmBox/"