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 ac0b05414f2..7567c8b8c8c 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 @@ -11,7 +11,6 @@ import org.jetbrains.kotlin.generators.util.TestGeneratorUtil import org.jetbrains.kotlin.incremental.* import org.jetbrains.kotlin.js.test.fir.* import org.jetbrains.kotlin.js.test.ir.* -import org.jetbrains.kotlin.js.testOld.AbstractDceTest import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.js.test.fir.AbstractFirLightTreeJsIrTextTest import org.jetbrains.kotlin.js.test.ir.AbstractMultiModuleOrderTest @@ -29,12 +28,6 @@ fun main(args: Array) { //generateTestDataForReservedWords() generateTestGroupSuite(args) { - testGroup("js/js.tests/tests-gen", "js/js.translator/testData", testRunnerMethodName = "runTest0") { - testClass { - model("dce/", pattern = "(.+)\\.js", targetBackend = TargetBackend.JS) - } - } - testGroup("js/js.tests/tests-gen", "compiler/testData", testRunnerMethodName = "runTest0") { testClass { model("klib/evolution", targetBackend = TargetBackend.JS_IR) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/testOld/AbstractDceTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/testOld/AbstractDceTest.kt deleted file mode 100644 index a454ceedbdc..00000000000 --- a/js/js.tests/test/org/jetbrains/kotlin/js/testOld/AbstractDceTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 2010-2021 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.testOld - -import junit.framework.TestCase -import org.jetbrains.kotlin.js.dce.DeadCodeElimination -import org.jetbrains.kotlin.js.dce.InputFile -import org.jetbrains.kotlin.js.dce.InputResource -import java.io.File - -abstract class AbstractDceTest : TestCase() { - fun doTest(filePath: String) { - val file = File(filePath) - val fileContents = file.readText() - val inputFile = InputFile(InputResource.file(filePath), null, - File(pathToOutputDir, file.relativeTo(File(pathToTestDir)).path).path, "main") - val dceResult = DeadCodeElimination.run(setOf(inputFile), extractDeclarations(REQUEST_REACHABLE_PATTERN, fileContents), true) { _, _ -> } - val reachableNodeStrings = dceResult.reachableNodes.map { it.toString().removePrefix(".") }.toSet() - - for (assertedDeclaration in extractDeclarations(ASSERT_REACHABLE_PATTERN, fileContents)) { - TestCase.assertTrue("Declaration $assertedDeclaration not reached", assertedDeclaration in reachableNodeStrings) - } - for (assertedDeclaration in extractDeclarations(ASSERT_UNREACHABLE_PATTERN, fileContents)) { - TestCase.assertTrue("Declaration $assertedDeclaration reached", assertedDeclaration !in reachableNodeStrings) - } - } - - private fun extractDeclarations(regex: Regex, fileContents: String): Set = - regex.findAll(fileContents).map { it.groupValues[1] }.toSet() - - companion object { - private val ASSERT_REACHABLE_PATTERN = Regex("^ *// *ASSERT_REACHABLE: (.+) *$", RegexOption.MULTILINE) - private val ASSERT_UNREACHABLE_PATTERN = Regex("^ *// *ASSERT_UNREACHABLE: (.+) *$", RegexOption.MULTILINE) - private val REQUEST_REACHABLE_PATTERN = Regex("^ *// *REQUEST_REACHABLE: (.+) *$", RegexOption.MULTILINE) - - private val pathToTestDir = "js/js.translator/testData/dce" - private val pathToOutputDir = System.getProperty("kotlin.js.test.root.out.dir") ?: error("'kotlin.js.test.root.out.dir' is not set") - } -} \ No newline at end of file diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/DceTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/DceTestGenerated.java deleted file mode 100644 index 6f551438706..00000000000 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/testOld/DceTestGenerated.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2010-2024 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.testOld; - -import com.intellij.testFramework.TestDataPath; -import org.jetbrains.kotlin.test.JUnit3RunnerWithInners; -import org.jetbrains.kotlin.test.KotlinTestUtils; -import org.jetbrains.kotlin.test.util.KtTestUtil; -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.GenerateJsTestsKt}. DO NOT MODIFY MANUALLY */ -@SuppressWarnings("all") -@TestMetadata("js/js.translator/testData/dce") -@TestDataPath("$PROJECT_ROOT") -@RunWith(JUnit3RunnerWithInners.class) -public class DceTestGenerated extends AbstractDceTest { - private void runTest(String testDataFilePath) { - KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); - } - - public void testAllFilesPresentInDce() { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("js/js.translator/testData/dce"), Pattern.compile("(.+)\\.js"), null, TargetBackend.JS, true); - } - - @TestMetadata("amd.js") - public void testAmd() { - runTest("js/js.translator/testData/dce/amd.js"); - } - - @TestMetadata("arrayAccess.js") - public void testArrayAccess() { - runTest("js/js.translator/testData/dce/arrayAccess.js"); - } - - @TestMetadata("commonjs.js") - public void testCommonjs() { - runTest("js/js.translator/testData/dce/commonjs.js"); - } - - @TestMetadata("cycle.js") - public void testCycle() { - runTest("js/js.translator/testData/dce/cycle.js"); - } - - @TestMetadata("localVarAndFunction.js") - public void testLocalVarAndFunction() { - runTest("js/js.translator/testData/dce/localVarAndFunction.js"); - } - - @TestMetadata("typeOf.js") - public void testTypeOf() { - runTest("js/js.translator/testData/dce/typeOf.js"); - } -} diff --git a/js/js.translator/testData/dce/amd.js b/js/js.translator/testData/dce/amd.js deleted file mode 100644 index 4c1b295fb70..00000000000 --- a/js/js.translator/testData/dce/amd.js +++ /dev/null @@ -1,19 +0,0 @@ -define(['exports'], function (exports) { - function foo() { - } - function bar() { - } - function ignore() { - } - - bar(); - - exports.foo = foo; - exports.bar = bar; - exports.ignore = ignore; -}); - -// REQUEST_REACHABLE: main.foo -// ASSERT_REACHABLE: main.foo -// ASSERT_REACHABLE: main.bar -// ASSERT_UNREACHABLE: main.ignore \ No newline at end of file diff --git a/js/js.translator/testData/dce/arrayAccess.js b/js/js.translator/testData/dce/arrayAccess.js deleted file mode 100644 index c5135d0b371..00000000000 --- a/js/js.translator/testData/dce/arrayAccess.js +++ /dev/null @@ -1,17 +0,0 @@ -(function(_) { - var x = {}; - function foo() { - return x["bar"](); - } - x.bar = function() { - return "bar"; - }; - x.baz = function() { - return "baz"; - }; - _.foo = foo; -})(module.exports); - -// REQUEST_REACHABLE: main.foo -// ASSERT_REACHABLE: x.bar -// ASSERT_UNREACHABLE: x.baz \ No newline at end of file diff --git a/js/js.translator/testData/dce/commonjs.js b/js/js.translator/testData/dce/commonjs.js deleted file mode 100644 index 49af27fe29c..00000000000 --- a/js/js.translator/testData/dce/commonjs.js +++ /dev/null @@ -1,17 +0,0 @@ -function foo() { -} -function bar() { -} -function ignore() { -} - -bar(); - -module.exports.foo = foo; -module.exports.bar = bar; -module.exports.ignore = ignore; - -// REQUEST_REACHABLE: main.foo -// ASSERT_REACHABLE: main.bar -// ASSERT_REACHABLE: main.foo -// ASSERT_UNREACHABLE: main.ignore \ No newline at end of file diff --git a/js/js.translator/testData/dce/cycle.js b/js/js.translator/testData/dce/cycle.js deleted file mode 100644 index f42ab73e5f0..00000000000 --- a/js/js.translator/testData/dce/cycle.js +++ /dev/null @@ -1,4 +0,0 @@ -function A() { -} -A.prototype = Object.create(A); -A.prototype.constructor = A; diff --git a/js/js.translator/testData/dce/localVarAndFunction.js b/js/js.translator/testData/dce/localVarAndFunction.js deleted file mode 100644 index ed818f029b6..00000000000 --- a/js/js.translator/testData/dce/localVarAndFunction.js +++ /dev/null @@ -1,27 +0,0 @@ -(function(_, Kotlin) { - Kotlin.defineInlineFunction("bar", Kotlin.wrapFunction(function() { - function baz() { - return "bar"; - } - return function() { - return baz(); - }; - })); - return _; -})(module.exports, require("kotlin")); - -(function(_) { - function baz() { - return "baz"; - } - - function foo() { - return baz(); - } - _.foo = foo; -})(module.exports); - - -// REQUEST_REACHABLE: main.foo -// ASSERT_REACHABLE: main.foo -// ASSERT_REACHABLE: baz \ No newline at end of file diff --git a/js/js.translator/testData/dce/typeOf.js b/js/js.translator/testData/dce/typeOf.js deleted file mode 100644 index ac971fa1962..00000000000 --- a/js/js.translator/testData/dce/typeOf.js +++ /dev/null @@ -1,15 +0,0 @@ -(function(_) { - var x = {}; - x.y = {}; - x.y.bar = function() { - return "bar"; - }; - function foo() { - return typeof x.y; - } - _.foo = foo; -})(module.exports); - -// REQUEST_REACHABLE: main.foo -// ASSERT_REACHABLE: x.y -// ASSERT_UNREACHABLE: x.y.bar \ No newline at end of file