Add type tests for JetPsiMatcher
This commit is contained in:
@@ -216,7 +216,8 @@ public class GenerateTests {
|
|||||||
"idea/tests/",
|
"idea/tests/",
|
||||||
"JetPsiMatcherTest",
|
"JetPsiMatcherTest",
|
||||||
AbstractJetPsiMatcherTest.class,
|
AbstractJetPsiMatcherTest.class,
|
||||||
testModel("idea/testData/jetPsiMatcher", "doTestExpressions")
|
testModel("idea/testData/jetPsiMatcher/expressions", "doTestExpressions"),
|
||||||
|
testModel("idea/testData/jetPsiMatcher/types", "doTestTypes")
|
||||||
);
|
);
|
||||||
|
|
||||||
generateTest(
|
generateTest(
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// NOT_EQUAL
|
||||||
|
val x: (s: String, b: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: (s: Boolean, b: String) -> Int
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// NOT_EQUAL
|
||||||
|
val x: String.(b: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: (s: String, b: Boolean) -> Int
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// NOT_EQUAL
|
||||||
|
val x: String
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: String?
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// NOT_EQUAL
|
||||||
|
val x: Map<String, Collection<Int>>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val y: Map<Collection<Int>>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
// NOT_EQUAL
|
||||||
|
val x: Collection<Int>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: MutableCollection<Int>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: String -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val y: String -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: (s: String, b: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: (x: String, y: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: String.(b: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: String.(n: Boolean) -> Int
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: String?
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val y: String?
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: Collection<String>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val y: Collection<String>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val x: Map<String, Collection<Int>>
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
val y: Map<String,Collection<Int>>
|
||||||
@@ -24,6 +24,7 @@ import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
|
|||||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||||
import org.jetbrains.jet.plugin.util.JetPsiMatcher;
|
import org.jetbrains.jet.plugin.util.JetPsiMatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -44,6 +45,24 @@ public abstract class AbstractJetPsiMatcherTest extends JetLiteFixture {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void doTestTypes(@NotNull String path) throws Exception {
|
||||||
|
String fileText = FileUtil.loadFile(new File(path));
|
||||||
|
String fileText2 = FileUtil.loadFile(new File(path + ".2"));
|
||||||
|
|
||||||
|
boolean equalityExpected = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// NOT_EQUAL") == null;
|
||||||
|
|
||||||
|
JetTypeReference typeRef = JetPsiFactory.createProperty(getProject(), fileText).getTypeRef();
|
||||||
|
JetTypeReference typeRef2 = JetPsiFactory.createProperty(getProject(), fileText2).getTypeRef();
|
||||||
|
|
||||||
|
assertNotNull(typeRef);
|
||||||
|
assertNotNull(typeRef2);
|
||||||
|
|
||||||
|
assertTrue(
|
||||||
|
"JetPsiMatcher.checkElementMatch() should return " + equalityExpected,
|
||||||
|
equalityExpected == JetPsiMatcher.checkElementMatch(typeRef, typeRef2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected JetCoreEnvironment createEnvironment() {
|
protected JetCoreEnvironment createEnvironment() {
|
||||||
return new JetCoreEnvironment(getTestRootDisposable(), new CompilerConfiguration());
|
return new JetCoreEnvironment(getTestRootDisposable(), new CompilerConfiguration());
|
||||||
|
|||||||
@@ -30,13 +30,8 @@ import org.jetbrains.jet.psi.AbstractJetPsiMatcherTest;
|
|||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@TestMetadata("idea/testData/jetPsiMatcher")
|
@InnerTestClasses({JetPsiMatcherTest.Expressions.class, JetPsiMatcherTest.Types.class})
|
||||||
@InnerTestClasses({JetPsiMatcherTest.Expressions.class})
|
|
||||||
public class JetPsiMatcherTest extends AbstractJetPsiMatcherTest {
|
public class JetPsiMatcherTest extends AbstractJetPsiMatcherTest {
|
||||||
public void testAllFilesPresentInJetPsiMatcher() throws Exception {
|
|
||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/jetPsiMatcher"), Pattern.compile("^(.+)\\.kt$"), true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@TestMetadata("idea/testData/jetPsiMatcher/expressions")
|
@TestMetadata("idea/testData/jetPsiMatcher/expressions")
|
||||||
@InnerTestClasses({Expressions.ArrayAccess.class, Expressions.BinaryExpr.class, Expressions.Call.class, Expressions.Const.class, Expressions.Misc.class, Expressions.SimpleName.class, Expressions.Super.class, Expressions.Throw.class, Expressions.UnaryExpr.class})
|
@InnerTestClasses({Expressions.ArrayAccess.class, Expressions.BinaryExpr.class, Expressions.Call.class, Expressions.Const.class, Expressions.Misc.class, Expressions.SimpleName.class, Expressions.Super.class, Expressions.Throw.class, Expressions.UnaryExpr.class})
|
||||||
public static class Expressions extends AbstractJetPsiMatcherTest {
|
public static class Expressions extends AbstractJetPsiMatcherTest {
|
||||||
@@ -377,10 +372,73 @@ public class JetPsiMatcherTest extends AbstractJetPsiMatcherTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/jetPsiMatcher/types")
|
||||||
|
public static class Types extends AbstractJetPsiMatcherTest {
|
||||||
|
public void testAllFilesPresentInTypes() throws Exception {
|
||||||
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("idea/testData/jetPsiMatcher/types"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functional1.kt")
|
||||||
|
public void testFunctional1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/functional1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functional2.kt")
|
||||||
|
public void testFunctional2() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/functional2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functional3.kt")
|
||||||
|
public void testFunctional3() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/functional3.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullable1.kt")
|
||||||
|
public void testNullable1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/nullable1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("user1.kt")
|
||||||
|
public void testUser1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/user1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("user2.kt")
|
||||||
|
public void testUser2() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/user2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_functional1.kt")
|
||||||
|
public void test_functional1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/_functional1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_functional2.kt")
|
||||||
|
public void test_functional2() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/_functional2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_nullable1.kt")
|
||||||
|
public void test_nullable1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/_nullable1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_user1.kt")
|
||||||
|
public void test_user1() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/_user1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("_user2.kt")
|
||||||
|
public void test_user2() throws Exception {
|
||||||
|
doTestTypes("idea/testData/jetPsiMatcher/types/_user2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite("JetPsiMatcherTest");
|
TestSuite suite = new TestSuite("JetPsiMatcherTest");
|
||||||
suite.addTestSuite(JetPsiMatcherTest.class);
|
|
||||||
suite.addTest(Expressions.innerSuite());
|
suite.addTest(Expressions.innerSuite());
|
||||||
|
suite.addTestSuite(Types.class);
|
||||||
return suite;
|
return suite;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user