added DiagnosticMessageTest to generator

This commit is contained in:
Svetlana Isakova
2013-10-15 16:30:00 +04:00
parent 2f02427c57
commit 4af0e1a4fc
3 changed files with 99 additions and 41 deletions
@@ -51,6 +51,7 @@ import org.jetbrains.jet.plugin.codeInsight.unwrap.AbstractUnwrapRemoveTest;
import org.jetbrains.jet.plugin.configuration.AbstractConfigureProjectByChangingFileTest;
import org.jetbrains.jet.plugin.folding.AbstractKotlinFoldingTest;
import org.jetbrains.jet.plugin.hierarchy.AbstractHierarchyTest;
import org.jetbrains.jet.plugin.highlighter.AbstractDiagnosticMessageTest;
import org.jetbrains.jet.plugin.highlighter.AbstractHighlightingTest;
import org.jetbrains.jet.plugin.intentions.AbstractCodeTransformationTest;
import org.jetbrains.jet.plugin.navigation.JetAbstractGotoSuperTest;
@@ -502,6 +503,13 @@ public class GenerateTests {
AbstractJetFormatterTest.class,
testModelWithPattern("idea/testData/formatter", "^([^\\.]+)\\.kt$", "doTest")
);
generateTest(
"idea/tests/",
"DiagnosticMessageTestGenerated",
AbstractDiagnosticMessageTest.class,
testModel("idea/testData/diagnosticMessage")
);
}
private static SimpleTestClassModel testModel(@NotNull String rootPath) {
@@ -42,7 +42,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
public class DiagnosticMessageTest extends JetLiteFixture {
public abstract class AbstractDiagnosticMessageTest extends JetLiteFixture {
private static final String DIAGNOSTICS_NUMBER_DIRECTIVE = "DIAGNOSTICS_NUMBER";
private static final String DIAGNOSTICS_DIRECTIVE = "DIAGNOSTICS";
@@ -56,15 +56,16 @@ public class DiagnosticMessageTest extends JetLiteFixture {
return PluginTestCaseBase.getTestDataPathBase() + "/diagnosticMessage/";
}
public void doTest(String name) throws Exception {
String fileName = name + ".kt";
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
public void doTest(String filePath) throws Exception {
File file = new File(filePath);
String fileName = file.getName();
String fileData = JetTestUtils.doLoadFile(new File(getTestDataPath() + fileName));
String fileData = JetTestUtils.doLoadFile(file);
Map<String,String> directives = JetTestUtils.parseDirectives(fileData);
int diagnosticNumber = computeDiagnosticNumber(directives);
final Set<DiagnosticFactory> diagnosticFactories = computeDiagnosticFactories(directives);
JetFile psiFile = createPsiFile(null, fileName, loadFile(fileName));
AnalyzeExhaust analyzeExhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegration(psiFile, Collections.<AnalyzerScriptParameter>emptyList());
BindingContext bindingContext = analyzeExhaust.getBindingContext();
@@ -78,6 +79,7 @@ public class DiagnosticMessageTest extends JetLiteFixture {
assertEquals("Expected diagnostics number mismatch:", diagnosticNumber, diagnostics.size());
int index = 1;
String name = FileUtil.getNameWithoutExtension(fileName);
for (Diagnostic diagnostic : diagnostics) {
String readableDiagnosticText;
String extension;
@@ -135,40 +137,4 @@ public class DiagnosticMessageTest extends JetLiteFixture {
}
return diagnosticFactories;
}
public void testConflictingSubstitutions() throws Exception {
doTest("conflictingSubstitutions");
}
public void testFunctionPlaceholder() throws Exception {
doTest("functionPlaceholder");
}
public void testRenderCollectionOfTypes() throws Exception {
doTest("renderCollectionOfTypes");
}
public void testInaccessibleOuterClassExpression() throws Exception {
doTest("inaccessibleOuterClassExpression");
}
public void testUpperBoundViolated() throws Exception {
doTest("upperBoundViolated");
}
public void testTypeMismatchWithNothing() throws Exception {
doTest("typeMismatchWithNothing");
}
public void testInvisibleMember() throws Exception {
doTest("invisibleMember");
}
public void testNumberValueTypes() throws Exception {
doTest("numberValueTypes");
}
public void testTypeInferenceExpectedTypeMismatch() throws Exception {
doTest("typeInferenceExpectedTypeMismatch");
}
}
@@ -0,0 +1,84 @@
/*
* Copyright 2010-2013 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.plugin.highlighter;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.plugin.highlighter.AbstractDiagnosticMessageTest;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("idea/testData/diagnosticMessage")
public class DiagnosticMessageTestGenerated extends AbstractDiagnosticMessageTest {
public void testAllFilesPresentInDiagnosticMessage() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/diagnosticMessage"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("conflictingSubstitutions.kt")
public void testConflictingSubstitutions() throws Exception {
doTest("idea/testData/diagnosticMessage/conflictingSubstitutions.kt");
}
@TestMetadata("functionPlaceholder.kt")
public void testFunctionPlaceholder() throws Exception {
doTest("idea/testData/diagnosticMessage/functionPlaceholder.kt");
}
@TestMetadata("inaccessibleOuterClassExpression.kt")
public void testInaccessibleOuterClassExpression() throws Exception {
doTest("idea/testData/diagnosticMessage/inaccessibleOuterClassExpression.kt");
}
@TestMetadata("invisibleMember.kt")
public void testInvisibleMember() throws Exception {
doTest("idea/testData/diagnosticMessage/invisibleMember.kt");
}
@TestMetadata("numberValueTypes.kt")
public void testNumberValueTypes() throws Exception {
doTest("idea/testData/diagnosticMessage/numberValueTypes.kt");
}
@TestMetadata("renderCollectionOfTypes.kt")
public void testRenderCollectionOfTypes() throws Exception {
doTest("idea/testData/diagnosticMessage/renderCollectionOfTypes.kt");
}
@TestMetadata("typeInferenceExpectedTypeMismatch.kt")
public void testTypeInferenceExpectedTypeMismatch() throws Exception {
doTest("idea/testData/diagnosticMessage/typeInferenceExpectedTypeMismatch.kt");
}
@TestMetadata("typeMismatchWithNothing.kt")
public void testTypeMismatchWithNothing() throws Exception {
doTest("idea/testData/diagnosticMessage/typeMismatchWithNothing.kt");
}
@TestMetadata("upperBoundViolated.kt")
public void testUpperBoundViolated() throws Exception {
doTest("idea/testData/diagnosticMessage/upperBoundViolated.kt");
}
}