You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/05/11 15:10:12 UTC

groovy git commit: split out LineColumn tests which differ between the old and new parsers

Repository: groovy
Updated Branches:
  refs/heads/parrot fff2b2ce5 -> f42c8b86e


split out LineColumn tests which differ between the old and new parsers


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

Branch: refs/heads/parrot
Commit: f42c8b86ef06c6b6bf58525aa6a606229cf59b04
Parents: fff2b2c
Author: paulk <pa...@asert.com.au>
Authored: Fri May 12 01:10:02 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Fri May 12 01:10:02 2017 +1000

----------------------------------------------------------------------
 gradle/pomconfigurer.gradle                     |  3 +
 .../org/codehaus/groovy/ast/LineColumnCheck.txt | 78 ----------------
 .../groovy/ast/LineColumnCheckTest.groovy       | 25 +++--
 .../groovy/ast/LineColumnCheck_antlr2.txt       | 96 ++++++++++++++++++++
 .../groovy/ast/LineColumnCheck_antlr4.txt       | 96 ++++++++++++++++++++
 5 files changed, 212 insertions(+), 86 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/f42c8b86/gradle/pomconfigurer.gradle
----------------------------------------------------------------------
diff --git a/gradle/pomconfigurer.gradle b/gradle/pomconfigurer.gradle
index 3f3f291..4c0f0d6 100644
--- a/gradle/pomconfigurer.gradle
+++ b/gradle/pomconfigurer.gradle
@@ -582,6 +582,9 @@ project.ext.pomConfigureClosureWithoutTweaks = {
             contributor {
                 name 'Alex Popescu'
             }
+            contributor {
+                name 'Martin Kempf'
+            }
         }
         mailingLists {
             mailingList {

http://git-wip-us.apache.org/repos/asf/groovy/blob/f42c8b86/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
index 635506f..a6f9af4 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck.txt
@@ -23,26 +23,6 @@ import java.lang.annotation.*
 class A {}
 :::[AnnotationNode,(2:1),(2:28)]
 
-###FieldNode:::
-public class Test {
-	public attribute = 6, second = 9
-	String prop = "property"
-}
-:::[FieldNode,(2:2),(2:22)][ConstantExpression,(2:21),(2:22)];
-[FieldNode,(2:24),(2:34)][ConstantExpression,(2:33),(2:34)];
-[FieldNode,(3:2),(3:26)][ConstantExpression,(3:16),(3:26)]
-
-###ifElse:::
-if (expression) {
-	
-} else {
-	
-}
-:::[IfStatement,(1:1),(5:2)];
-[BooleanExpression,(1:5),(1:15)][VariableExpression,(1:5),(1:15)];
-[BlockStatement,(1:17),(3:3)];
-[BlockStatement,(3:8),(5:2)]
-
 ###ifWithoutElse:::
 if (expression) {
 	
@@ -50,17 +30,6 @@ if (expression) {
 }
 :::[IfStatement,(1:1),(4:2)];[BlockStatement,(1:17),(4:2)]
 
-###ifElseIf:::
-if (expression) {
-
-	
-} else if (expression2) {
-
-
-}
-:::[IfStatement,(1:1),(7:2)];[BlockStatement,(1:17),(4:3)];
-[IfStatement,(4:8),(7:2)];[BlockStatement,(4:25),(7:2)]
-
 ###ifNested:::
 if (expression) {
 
@@ -92,53 +61,6 @@ for (a in (1..42)) {
 }
 :::[ForStatement,(1:1),(4:2)];[BlockStatement,(1:20),(4:2)]
 
-###tryCatch:::
-try {
-	
-} catch(e) {
-	
-	
-}
-:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(3:3)];
-[CatchStatement,(3:3),(6:2)][BlockStatement,(3:12),(6:2)]
-
-###tryFinally:::
-try {
-
-	
-} finally {
-
-}
-:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(4:3)];
-[BlockStatement,(4:3),(6:2)][BlockStatement,(4:11),(6:2)]
-
-###tryCatchFinally():::
-try {
-
-} catch(e) {
-
-} finally {
-
-}
-:::[TryCatchStatement,(1:1),(7:2)][BlockStatement,(1:5),(3:3)];
-[CatchStatement,(3:3),(5:3)][BlockStatement,(3:12),(5:3)];
-[BlockStatement,(5:3),(7:2)][BlockStatement,(5:11),(7:2)]
-
-###tryMultiCatchFinally:::
-try {
-
-} catch(e) {
-	
-} catch(e) {
-	
-} finally {
-	
-}
-:::[TryCatchStatement,(1:1),(9:2)][BlockStatement,(1:5),(3:3)];
-[CatchStatement,(3:3),(5:3)][BlockStatement,(3:12),(5:3)];
-[CatchStatement,(5:3),(7:3)][BlockStatement,(5:12),(7:3)];
-[BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]
-
 ###switchCase:::
 switch (expression) {
 	case 1 : log = 1

http://git-wip-us.apache.org/repos/asf/groovy/blob/f42c8b86/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy b/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
index 46a9acf..43aef5a 100644
--- a/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheckTest.groovy
@@ -59,8 +59,11 @@ import org.junit.Test
 import org.junit.runner.RunWith
 import org.junit.runners.Parameterized
 
-/*
- * Tests the LineColumn information in file specified in TEST_FILE_PATH
+/**
+ * Tests the LineColumn information in file with path specified by the prefix TEST_FILE_PREFIX.
+ * The base version contains tests that should work with both the antlr2 and antlr4 parser.
+ * The suffixed versions work with just the respective parser. In general, the antlr4 parser
+ * has more accurate line/column information in a number of situations.
  * 
  * The file in the specified path should look like:
  * 
@@ -80,15 +83,11 @@ import org.junit.runners.Parameterized
  * [BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]
  * 
  * [<NodeType>,(<line>:<column>),(<lastLine>:<lastColumn>)]
- * 
- * @author <a href="mailto:martin.kempf@gmail.com">Martin Kempf</a>
- *
  */
-
 @RunWith(Parameterized)
 class LineColumnCheckTest extends ASTTest {
 
-    static final String TEST_FILE_PATH = './src/test/org/codehaus/groovy/ast/LineColumnCheck.txt'
+    static final String TEST_FILE_PREFIX = './src/test/org/codehaus/groovy/ast/LineColumnCheck'
 
     private LineCheckVisitor visitor
     private String name
@@ -97,7 +96,17 @@ class LineColumnCheckTest extends ASTTest {
 
     @Parameterized.Parameters(name = 'Test {0}: Source: {1} Expected: {2}')
     static Iterable<Object[]> data() {
-        String content = new File(TEST_FILE_PATH).text
+        List testdata = extractData("${TEST_FILE_PREFIX}.txt")
+        if (System.getProperty('groovy.antlr4') != 'false') {
+            testdata += extractData("${TEST_FILE_PREFIX}_antlr4.txt")
+        } else {
+            testdata += extractData("${TEST_FILE_PREFIX}_antlr2.txt")
+        }
+        testdata
+    }
+
+    private static List extractData(String test_file_path) {
+        String content = new File(test_file_path).text
         String[] tests = content.split('###')
         tests = tests.drop(1) // remove apache header
         List testdata = []

http://git-wip-us.apache.org/repos/asf/groovy/blob/f42c8b86/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
new file mode 100644
index 0000000..95866a0
--- /dev/null
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr2.txt
@@ -0,0 +1,96 @@
+====
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you 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.
+====
+
+###FieldNode:::
+public class Test {
+	public attribute = 6, second = 9
+	String prop = "property"
+}
+:::[FieldNode,(2:2),(2:22)][ConstantExpression,(2:21),(2:22)];
+[FieldNode,(2:24),(2:34)][ConstantExpression,(2:33),(2:34)];
+[FieldNode,(3:2),(3:26)][ConstantExpression,(3:16),(3:26)]
+
+###ifElse:::
+if (expression) {
+
+} else {
+
+}
+:::[IfStatement,(1:1),(5:2)];
+[BooleanExpression,(1:5),(1:15)][VariableExpression,(1:5),(1:15)];
+[BlockStatement,(1:17),(3:3)];
+[BlockStatement,(3:8),(5:2)]
+
+###ifElseIf:::
+if (expression) {
+
+
+} else if (expression2) {
+
+
+}
+:::[IfStatement,(1:1),(7:2)];[BlockStatement,(1:17),(4:3)];
+[IfStatement,(4:8),(7:2)];[BlockStatement,(4:25),(7:2)]
+
+###tryCatch:::
+try {
+
+} catch(e) {
+
+
+}
+:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(3:3)];
+[CatchStatement,(3:3),(6:2)][BlockStatement,(3:12),(6:2)]
+
+###tryFinally:::
+try {
+
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(4:3)];
+[BlockStatement,(4:3),(6:2)][BlockStatement,(4:11),(6:2)]
+
+###tryCatchFinally():::
+try {
+
+} catch(e) {
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(7:2)][BlockStatement,(1:5),(3:3)];
+[CatchStatement,(3:3),(5:3)][BlockStatement,(3:12),(5:3)];
+[BlockStatement,(5:3),(7:2)][BlockStatement,(5:11),(7:2)]
+
+###tryMultiCatchFinally:::
+try {
+
+} catch(e) {
+
+} catch(e) {
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(9:2)][BlockStatement,(1:5),(3:3)];
+[CatchStatement,(3:3),(5:3)][BlockStatement,(3:12),(5:3)];
+[CatchStatement,(5:3),(7:3)][BlockStatement,(5:12),(7:3)];
+[BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]

http://git-wip-us.apache.org/repos/asf/groovy/blob/f42c8b86/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
new file mode 100644
index 0000000..da8d573
--- /dev/null
+++ b/src/test/org/codehaus/groovy/ast/LineColumnCheck_antlr4.txt
@@ -0,0 +1,96 @@
+====
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you 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.
+====
+
+###FieldNode:::
+public class Test {
+	public attribute = 6, second = 9
+	String prop = "property"
+}
+:::[FieldNode,(2:2),(2:34)][ConstantExpression,(2:21),(2:22)];
+[FieldNode,(2:24),(2:34)][ConstantExpression,(2:33),(2:34)];
+[FieldNode,(3:2),(3:26)][ConstantExpression,(3:16),(3:26)]
+
+###ifElse:::
+if (expression) {
+
+} else {
+
+}
+:::[IfStatement,(1:1),(5:2)];
+[BooleanExpression,(1:4),(1:16)][VariableExpression,(1:4),(1:16)];
+[BlockStatement,(1:17),(3:2)];
+[BlockStatement,(3:8),(5:2)]
+
+###ifElseIf:::
+if (expression) {
+
+
+} else if (expression2) {
+
+
+}
+:::[IfStatement,(1:1),(7:2)];[BlockStatement,(1:17),(4:2)];
+[IfStatement,(4:8),(7:2)];[BlockStatement,(4:25),(7:2)]
+
+###tryCatch:::
+try {
+
+} catch(e) {
+
+
+}
+:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(3:2)];
+[CatchStatement,(3:12),(6:2)][BlockStatement,(3:12),(6:2)]
+
+###tryFinally:::
+try {
+
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(6:2)][BlockStatement,(1:5),(4:2)];
+[BlockStatement,(4:3),(6:2)][BlockStatement,(4:11),(6:2)]
+
+###tryCatchFinally():::
+try {
+
+} catch(e) {
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(7:2)][BlockStatement,(1:5),(3:2)];
+[CatchStatement,(3:12),(5:2)][BlockStatement,(3:12),(5:2)];
+[BlockStatement,(5:3),(7:2)][BlockStatement,(5:11),(7:2)]
+
+###tryMultiCatchFinally:::
+try {
+
+} catch(e) {
+
+} catch(e) {
+
+} finally {
+
+}
+:::[TryCatchStatement,(1:1),(9:2)][BlockStatement,(1:5),(3:2)];
+[CatchStatement,(3:12),(5:2)][BlockStatement,(3:12),(5:2)];
+[CatchStatement,(5:12),(7:2)][BlockStatement,(5:12),(7:2)];
+[BlockStatement,(7:3),(9:2)][BlockStatement,(7:11),(9:2)]