JS: added tests for recursion cycle in inline functions
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||
|
||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||
|
||||
inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
||||
|
||||
inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
kotlin.inline() internal fun f(): kotlin.Unit
|
||||
kotlin.inline() internal fun g(): kotlin.Unit
|
||||
kotlin.inline() internal fun h(): kotlin.Unit
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||
|
||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||
|
||||
inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h { <!INLINE_CALL_CYCLE!>f()<!> }<!>
|
||||
|
||||
inline fun h(fn: ()->Unit): Unit = <!INLINE_CALL_CYCLE!>fn()<!>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
kotlin.inline() internal fun f(): kotlin.Unit
|
||||
kotlin.inline() internal fun g(): kotlin.Unit
|
||||
kotlin.inline() internal fun h(/*0*/ fn: () -> kotlin.Unit): kotlin.Unit
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||
|
||||
public inline fun f():Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||
|
||||
public inline fun g(): Unit = <!INLINE_CALL_CYCLE!>h()<!>
|
||||
|
||||
public inline fun h(): Unit = <!INLINE_CALL_CYCLE!>f()<!>
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package
|
||||
|
||||
kotlin.inline() public fun f(): kotlin.Unit
|
||||
kotlin.inline() public fun g(): kotlin.Unit
|
||||
kotlin.inline() public fun h(): kotlin.Unit
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
// !DIAGNOSTICS: -NOTHING_TO_INLINE
|
||||
|
||||
inline fun f(): Unit = <!INLINE_CALL_CYCLE!>g()<!>
|
||||
|
||||
inline fun g(): Unit = <!INLINE_CALL_CYCLE!>run { <!INLINE_CALL_CYCLE!>f()<!> }<!>
|
||||
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
kotlin.inline() internal fun f(): kotlin.Unit
|
||||
kotlin.inline() internal fun g(): kotlin.Unit
|
||||
@@ -25,5 +25,6 @@
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="android-compiler-plugin" scope="TEST" />
|
||||
<orderEntry type="module" module-name="js.serializer" />
|
||||
<orderEntry type="module" module-name="js.translator" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
+5
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration;
|
||||
import org.jetbrains.kotlin.context.GlobalContext;
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl;
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS;
|
||||
import org.jetbrains.kotlin.js.config.Config;
|
||||
import org.jetbrains.kotlin.js.config.EcmaVersion;
|
||||
import org.jetbrains.kotlin.js.config.LibrarySourcesConfig;
|
||||
import org.jetbrains.kotlin.js.config.LibrarySourcesConfigWithCaching;
|
||||
@@ -93,4 +94,8 @@ public abstract class AbstractJetDiagnosticsTestWithJsStdLib extends AbstractJet
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
protected Config getConfig() {
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.checkers
|
||||
|
||||
import org.jetbrains.kotlin.context.GlobalContext
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
||||
import org.jetbrains.kotlin.js.analyzer.JsAnalysisResult
|
||||
import org.jetbrains.kotlin.js.facade.K2JSTranslator
|
||||
import org.jetbrains.kotlin.js.facade.MainCallParameters
|
||||
import org.jetbrains.kotlin.js.facade.exceptions.TranslationException
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.resolve.BindingTrace
|
||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics
|
||||
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils.hasError
|
||||
|
||||
public abstract class AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation : AbstractJetDiagnosticsTestWithJsStdLib() {
|
||||
override fun analyzeModuleContents(
|
||||
context: GlobalContext,
|
||||
jetFiles: List<JetFile>,
|
||||
module: ModuleDescriptorImpl,
|
||||
moduleTrace: BindingTrace
|
||||
) {
|
||||
val analysisResult = TopDownAnalyzerFacadeForJS.analyzeFilesWithGivenTrace(jetFiles, moduleTrace, module, getConfig())
|
||||
val diagnostics = analysisResult.bindingTrace.getBindingContext().getDiagnostics()
|
||||
|
||||
if (!hasError(diagnostics)) {
|
||||
val translator = K2JSTranslator(getConfig())
|
||||
translator.translate(jetFiles, MainCallParameters.noCall(), analysisResult)
|
||||
}
|
||||
}
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* 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.checkers;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.InnerTestClasses;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.JetTestUtils;
|
||||
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/diagnostics/testsWithJsStdLibAndBackendCompilation")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@InnerTestClasses({
|
||||
JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated.Inline.class,
|
||||
})
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class JetDiagnosticsTestWithJsStdLibAndBackendCompilationGenerated extends AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation {
|
||||
public void testAllFilesPresentInTestsWithJsStdLibAndBackendCompilation() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class Inline extends AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation {
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("recursionCycle.kt")
|
||||
public void testRecursionCycle() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycle.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("recursionCycleLambda.kt")
|
||||
public void testRecursionCycleLambda() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleLambda.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("recursionCycleWithPublicFun.kt")
|
||||
public void testRecursionCycleWithPublicFun() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithPublicFun.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("recursionCycleWithStdlibCall.kt")
|
||||
public void testRecursionCycleWithStdlibCall() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/inline/recursionCycleWithStdlibCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,6 +135,10 @@ fun main(args: Array<String>) {
|
||||
model("diagnostics/testsWithJsStdLib")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractJetDiagnosticsTestWithJsStdLibAndBackendCompilation>()) {
|
||||
model("diagnostics/testsWithJsStdLibAndBackendCompilation")
|
||||
}
|
||||
|
||||
testClass(javaClass<AbstractResolveTest>()) {
|
||||
model("resolve", extension = "resolve")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user