You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by cc...@apache.org on 2015/10/07 21:26:47 UTC

[27/37] incubator-groovy git commit: ASTMatcher: Add test case for simplified AST matcher with 2 constraints in the same block

ASTMatcher: Add test case for simplified AST matcher with 2 constraints in the same block


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/3d6d571d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/3d6d571d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/3d6d571d

Branch: refs/heads/master
Commit: 3d6d571dd3dea0f6d93c8af810f89249ea9ca570
Parents: bea3042
Author: Cedric Champeau <ce...@gmail.com>
Authored: Wed Nov 12 11:18:08 2014 +0100
Committer: Sergei Egorov <bs...@gmail.com>
Committed: Mon Sep 28 14:33:12 2015 +0300

----------------------------------------------------------------------
 .../groovy/macro/matcher/ASTMatcherTest.groovy   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/3d6d571d/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/matcher/ASTMatcherTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/matcher/ASTMatcherTest.groovy b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/matcher/ASTMatcherTest.groovy
index 35301e4..8b5660e 100644
--- a/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/matcher/ASTMatcherTest.groovy
+++ b/subprojects/groovy-macro/src/test/groovy/org/codehaus/groovy/macro/matcher/ASTMatcherTest.groovy
@@ -727,4 +727,23 @@ class ASTMatcherTest extends GroovyTestCase {
         }
     }
 
+    void testInlineMacroCombinationWithSimplifiedConstraints() {
+        use(ASTMatcher) {
+            def ast1 = macro { a + b }
+            def ast2 = macro { b + b }
+            def ast3 = macro { b + c }
+            def ast4 = macro { b - b }
+            def pattern = macro {
+                a + b
+            }.withConstraints {
+                placeholder a
+                anyToken()
+            }
+            assert pattern instanceof BinaryExpression
+            assert ast1.matches(pattern)
+            assert ast2.matches(pattern)
+            assert !ast3.matches(pattern)
+            assert ast4.matches(pattern)
+        }
+    }
 }