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:
Alexander Udalov
2016-09-28 12:45:44 +03:00
parent 9fb9c12f5e
commit 74d6ef73d4
5 changed files with 9 additions and 9 deletions
+2 -2
View File
@@ -1,3 +1,3 @@
val fibwp = test.Fibwp(5)
val fibwp = test.Fibwp_lang(5)
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 {
File file = new File(fullPath);
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());
return content;
} catch (IOException e) {
@@ -55,6 +55,7 @@ public class GenerateNotNullAssertionsTest extends CodegenTestCase {
configuration.put(JVMConfigurationKeys.DISABLE_PARAM_ASSERTIONS, disableParamAssertions);
myEnvironment = KotlinCoreEnvironment.createForTests(getTestRootDisposable(), configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES);
myFiles = null;
}
private void loadSource(@NotNull String fileName) {
@@ -109,9 +109,10 @@ public class OuterClassGenTest extends CodegenTestCase {
public void testLocalObjectInLambdaInlinedIntoObject() throws Exception {
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
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");
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
objectInLambda, "inlineObject");
@@ -134,9 +135,10 @@ public class OuterClassGenTest extends CodegenTestCase {
public void testLambdaInLambdaInlinedIntoObject() throws Exception {
OuterClassInfo intoObjectInfo = new OuterClassInfo("foo/Bar", "objectInLambdaInlinedIntoObject", "()V");
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");
doCustomTest("foo/Bar\\$objectInLambdaInlinedIntoObject\\$\\$inlined\\$inlineFoo\\$1\\$lambda\\$1",
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.addKotlinSourceRoots
import org.jetbrains.kotlin.script.KotlinScriptDefinitionFromTemplate
import org.jetbrains.kotlin.script.ScriptTemplateDefinition
import org.jetbrains.kotlin.scripts.ScriptWithIntParam
import org.jetbrains.kotlin.scripts.TestKotlinScriptDependenciesResolver
import org.jetbrains.kotlin.test.ConfigurationKind
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestJdkKind
@@ -107,8 +105,6 @@ class ScriptGenTest : CodegenTestCase() {
myEnvironment = KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
for (path in sourcePaths) {
loadFile(path)
}
loadFiles(*sourcePaths.toTypedArray())
}
}