Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id E2B42200C76 for ; Sat, 13 May 2017 14:16:27 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DF959160BC9; Sat, 13 May 2017 12:16:27 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D687B160BB7 for ; Sat, 13 May 2017 14:16:26 +0200 (CEST) Received: (qmail 94208 invoked by uid 500); 13 May 2017 12:16:25 -0000 Mailing-List: contact commits-help@groovy.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@groovy.apache.org Delivered-To: mailing list commits@groovy.apache.org Received: (qmail 94190 invoked by uid 99); 13 May 2017 12:16:24 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 May 2017 12:16:24 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C99E8DFBAB; Sat, 13 May 2017 12:16:24 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: paulk@apache.org To: commits@groovy.apache.org Date: Sat, 13 May 2017 12:16:24 -0000 Message-Id: <86597182a3c04891875a6c6e3b63cfe0@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] groovy git commit: split out LineColumn tests which differ between the old and new parsers archived-at: Sat, 13 May 2017 12:16:28 -0000 Repository: groovy Updated Branches: refs/heads/GROOVY_2_6_X 26e31f1e5 -> 6f78baf82 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/0d18108f Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/0d18108f Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/0d18108f Branch: refs/heads/GROOVY_2_6_X Commit: 0d18108ffe058460e7db90ffa9d33e6b7c22825b Parents: 26e31f1 Author: paulk Authored: Fri May 12 01:10:02 2017 +1000 Committer: paulk Committed: Sat May 13 21:55:21 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/0d18108f/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/0d18108f/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/0d18108f/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)] * * [,(:),(:)] - * - * @author Martin Kempf - * */ - @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 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/0d18108f/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/0d18108f/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)]