Rewritten CheckLoadVariablesTableTest to test generation framework.
This commit is contained in:
+7
-33
@@ -19,19 +19,12 @@ package org.jetbrains.jet.codegen;
|
||||
import com.google.common.io.Files;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.*;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -47,18 +40,12 @@ import java.util.regex.Pattern;
|
||||
* @author Natalia.Ukhorskaya
|
||||
*/
|
||||
|
||||
public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
public abstract class AbstractCheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
|
||||
private final File ktFile;
|
||||
private File ktFile;
|
||||
private JetCoreEnvironment jetCoreEnvironment;
|
||||
|
||||
public CheckLocalVariablesTableTest(File ktFile) {
|
||||
this.ktFile = ktFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return ktFile.getName();
|
||||
public AbstractCheckLocalVariablesTableTest() {
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,8 +60,8 @@ public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
protected void doTest(@NotNull String ktFileName) throws Exception {
|
||||
ktFile = new File(ktFileName);
|
||||
String text = FileUtil.loadFile(ktFile);
|
||||
|
||||
JetFile psiFile = JetTestUtils.createFile(ktFile.getName(), text, jetCoreEnvironment.getProject());
|
||||
@@ -82,7 +69,7 @@ public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
|
||||
final ClassFileFactory factory = GenerationUtils.compileFileGetClassFileFactoryForTest(psiFile);
|
||||
|
||||
String modifiedTestName = this.getName().replace(".kt", ".class");
|
||||
String modifiedTestName = ktFile.getName().replace(".kt", ".class");
|
||||
boolean isClassFound = false;
|
||||
for (String filename : factory.files()) {
|
||||
if (filename.equals(modifiedTestName)) {
|
||||
@@ -113,19 +100,6 @@ public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||
}
|
||||
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkLocalVariablesTable", true,
|
||||
new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath,
|
||||
@NotNull String name,
|
||||
@NotNull File file) {
|
||||
return new CheckLocalVariablesTableTest(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class LocalVariable {
|
||||
private final String name;
|
||||
private final String type;
|
||||
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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.jet.codegen;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import java.io.File;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.test.InnerTestClasses;
|
||||
import org.jetbrains.jet.test.TestMetadata;
|
||||
|
||||
import org.jetbrains.jet.codegen.AbstractCheckLocalVariablesTableTest;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||
@TestMetadata("compiler/testData/checkLocalVariablesTable")
|
||||
public class CheckLocalVariablesTableTestGenerated extends AbstractCheckLocalVariablesTableTest {
|
||||
public void testAllFilesPresentInCheckLocalVariablesTable() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/checkLocalVariablesTable"), "kt", true);
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$1.kt")
|
||||
public void testNamespace$foo$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$1$1.kt")
|
||||
public void testNamespace$foo$1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$1$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo$a$1.kt")
|
||||
public void testNamespace$foo$a$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo$a$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("namespace$foo1$1.kt")
|
||||
public void testNamespace$foo1$1() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/namespace$foo1$1.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("someClass.kt")
|
||||
public void testSomeClass() throws Exception {
|
||||
doTest("compiler/testData/checkLocalVariablesTable/someClass.kt");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,6 +20,7 @@ import junit.framework.TestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve;
|
||||
import org.jetbrains.jet.checkers.AbstractJetPsiCheckerTest;
|
||||
import org.jetbrains.jet.codegen.AbstractCheckLocalVariablesTableTest;
|
||||
import org.jetbrains.jet.codegen.AbstractDataClassCodegenTest;
|
||||
import org.jetbrains.jet.codegen.AbstractIntrinsicsTestCase;
|
||||
import org.jetbrains.jet.codegen.AbstractMultiDeclTestCase;
|
||||
@@ -71,6 +72,13 @@ public class GenerateTests {
|
||||
testModel("compiler/testData/codegen/dataClasses", "blackBoxFileByFullPath")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"CheckLocalVariablesTableTestGenerated",
|
||||
AbstractCheckLocalVariablesTableTest.class,
|
||||
testModel("compiler/testData/checkLocalVariablesTable", "doTest")
|
||||
);
|
||||
|
||||
generateTest(
|
||||
"compiler/tests/",
|
||||
"IntrinsicsTestGenerated",
|
||||
|
||||
Reference in New Issue
Block a user