SSR: remove 1 broken test, fix 2 broken tests
authorBas Leijdekkers <basleijdekkers@gmail.com>
Fri, 21 Oct 2016 15:07:27 +0000 (17:07 +0200)
committerBas Leijdekkers <basleijdekkers@gmail.com>
Fri, 21 Oct 2016 16:59:49 +0000 (18:59 +0200)
platform/structuralsearch/testSource/com/intellij/structuralsearch/StructuralSearchTest.java
platform/structuralsearch/testSource/com/intellij/structuralsearch/impl/matcher/compiler/StringToConstraintsTransformerTest.java

index 752abe82e2b56d01629c113ca124c26118771e0a..0633b75f32398462c1b42ac14163f21f8f4c7a71 100644 (file)
@@ -2353,14 +2353,6 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
       3
     );
 
-    final String s125 = "a=1;";
-    final String s126 = "'t:[regex(a)]";
-
-    try {
-      findMatchesCount(s125,s126);
-      assertFalse("spaces around reg exp check",false);
-    } catch(MalformedPatternException ex) {}
-
     final String s101 = "class A { void b() { String d; String e; String[] f; f.length=1; f.length=1; } }";
     final String s102 = "'_:[ref('T)] '_;";
 
@@ -2370,23 +2362,6 @@ public class StructuralSearchTest extends StructuralSearchTestCase {
       1
     );
 
-    final String s103 = " a=1; ";
-    final String s104 = "'T:{ ;";
-    try {
-      findMatchesCount(s103,s104);
-      assertFalse("incorrect reg exp",false);
-    } catch(MalformedPatternException ex) {
-    }
-
-    final String s106 = "'_ReturnType 'MethodName('_ParameterType '_Parameter);";
-    final String s105 = " aaa; ";
-
-    try {
-      findMatchesCount(s105,s106);
-      assertFalse("incorrect reg exp 2",false);
-    } catch(UnsupportedPatternException ex) {
-    }
-
     String s107 = "class A {\n" +
                   "  /* */\n" +
                   "  void a() {\n" +
index bfdadf49a45efe9d4e085445ddc410a6f312c963..472db4c9cbcfdcd13b5350721c916f6af9e82e82 100644 (file)
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2016 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 com.intellij.structuralsearch.impl.matcher.compiler;
 
 import com.intellij.structuralsearch.MalformedPatternException;
@@ -239,6 +254,18 @@ public class StringToConstraintsTransformerTest {
     test("'a:[regex(  .* ) ]");
   }
 
+  @Test(expected = MalformedPatternException.class)
+  public void testInvalidRegex() {
+    test("'T:{ ;");
+  }
+
+  @Test
+  public void testNoSpacesSurroundingRegexNeeded() {
+    test("'t:[regex(a)]");
+    final MatchVariableConstraint constraint = myOptions.getVariableConstraint("t");
+    assertEquals("a", constraint.getRegExp());
+  }
+
   private void test(String pattern) {
     myOptions.setSearchPattern(pattern);
     StringToConstraintsTransformer.transformOldPattern(myOptions);