Prevent double initialization in codegen tests, fix ScriptGenTest#testDependentScripts
Add an assertion to prevent duplicate initialization of CodegenTestFiles instance in CodegenTestCase, which was happening in ScriptGenTest with multiple invocation of loadFile()
This commit is contained in:
+2
-2
@@ -1,3 +1,3 @@
|
|||||||
val fibwp = test.Fibwp(5)
|
val fibwp = test.Fibwp_lang(5)
|
||||||
val callResult = fibwp.fib(4)
|
val callResult = fibwp.fib(4)
|
||||||
val result = fibwp.num + fibwp.result - 5
|
val result = fibwp.num + fibwp.result - 5
|
||||||
|
|||||||
@@ -252,6 +252,7 @@ public abstract class CodegenTestCase extends KtUsefulTestCase {
|
|||||||
try {
|
try {
|
||||||
File file = new File(fullPath);
|
File file = new File(fullPath);
|
||||||
String content = FileUtil.loadFile(file, Charsets.UTF_8.name(), true);
|
String content = FileUtil.loadFile(file, Charsets.UTF_8.name(), true);
|
||||||
|
assert myFiles == null : "Should not initialize myFiles twice";
|
||||||
myFiles = CodegenTestFiles.create(file.getName(), content, myEnvironment.getProject());
|
myFiles = CodegenTestFiles.create(file.getName(), content, myEnvironment.getProject());
|
||||||
return content;
|
return content;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
|
|||||||
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, disableParamAssertions);
|
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, disableParamAssertions);
|
||||||
|
|
||||||
myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
|
||||||
|
myFiles = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSource(@NotNull String fileName) {
|
private void loadSource(@NotNull String fileName) {
|
||||||
|
|||||||
@@ -109,9 +109,10 @@ public class OuterClassGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testLocalObjectInLambdaInlinedIntoObject() throws Exception {
|
public void testLocalObjectInLambdaInlinedIntoObject() throws Exception {
|
||||||
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
|
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
|
||||||
|
|
||||||
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineObject");
|
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineObject");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testLocalObjectInLambdaInlinedIntoObject2() throws Exception {
|
||||||
OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "run", "()V");
|
OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "run", "()V");
|
||||||
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
|
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
|
||||||
objectInLambda, "inlineObject");
|
objectInLambda, "inlineObject");
|
||||||
@@ -134,9 +135,10 @@ public class OuterClassGenTest extends CodegenTestCase {
|
|||||||
|
|
||||||
public void testLambdaInLambdaInlinedIntoObject() throws Exception {
|
public void testLambdaInLambdaInlinedIntoObject() throws Exception {
|
||||||
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
|
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
|
||||||
|
|
||||||
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineLambda");
|
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1", intoObjectInfo, "inlineLambda");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testLambdaInLambdaInlinedIntoObject2() throws Exception {
|
||||||
OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "invoke", "()V");
|
OuterClassInfo objectInLambda = new OuterClassInfo("foo/Bar$objectInLambdaInlinedIntoObject$$inlined$inlineFoo$1", "invoke", "()V");
|
||||||
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
|
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
|
||||||
objectInLambda, "inlineLambda");
|
objectInLambda, "inlineLambda");
|
||||||
|
|||||||
@@ -24,9 +24,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
|||||||
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||||
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||||
import org.jetbrains.kotlin.script.KotlinScriptDefinitionFromTemplate
|
import org.jetbrains.kotlin.script.KotlinScriptDefinitionFromTemplate
|
||||||
import org.jetbrains.kotlin.script.ScriptTemplateDefinition
|
|
||||||
import org.jetbrains.kotlin.scripts.ScriptWithIntParam
|
import org.jetbrains.kotlin.scripts.ScriptWithIntParam
|
||||||
import org.jetbrains.kotlin.scripts.TestKotlinScriptDependenciesResolver
|
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
import org.jetbrains.kotlin.test.TestJdkKind
|
import org.jetbrains.kotlin.test.TestJdkKind
|
||||||
@@ -107,8 +105,6 @@ class ScriptGenTest : CodegenTestCase() {
|
|||||||
|
|
||||||
myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||||
|
|
||||||
for (path in sourcePaths) {
|
loadFiles(*sourcePaths.toTypedArray())
|
||||||
loadFile(path)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user