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 2020/04/07 03:23:27 UTC

[groovy] branch master updated (b6cfa93 -> d0f8a09)

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git.


    from b6cfa93  Use JDK 11.0.6 on github actions
     new 64c94a2  GROOVY-9194: Groovy fails when a script starts with a #
     new d0f8a09  reinstate disabled test

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/codehaus/groovy/ast/ModuleNode.java  |  6 +++---
 src/test/org/codehaus/groovy/ast/ModuleNodeTest.java   | 18 +++++++++++-------
 .../groovy/syntax/parser/TestParserSupport.java        | 12 ++++++------
 3 files changed, 20 insertions(+), 16 deletions(-)


[groovy] 02/02: reinstate disabled test

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit d0f8a09ff7bd943870665da17f906a057debd228
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Apr 7 13:20:11 2020 +1000

    reinstate disabled test
---
 src/test/org/codehaus/groovy/ast/ModuleNodeTest.java         |  9 +++------
 .../org/codehaus/groovy/syntax/parser/TestParserSupport.java | 12 ++++++------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java b/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
index d816156..e38a0c6 100644
--- a/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
+++ b/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
@@ -27,14 +27,11 @@ import java.util.List;
  */
 public class ModuleNodeTest extends TestParserSupport {
 
-    public void testStatementClass_FAILS() throws Exception {
-        if (notYetImplemented()) return;
-
+    public void testStatementClass() {
         ModuleNode module = parse("x = [1, 2, 3]; println(x)", "Cheese.groovy");
+        assertFalse("Should have statements", module.getStatementBlock().isEmpty());
 
-        assertTrue("Should have statements", !module.getStatementBlock().isEmpty());
-
-        List classes = module.getClasses();
+        List<ClassNode> classes = module.getClasses();
         assertEquals("Number of classes", 1, classes.size());
 
         ClassNode classNode = (ClassNode) classes.get(0);
diff --git a/src/test/org/codehaus/groovy/syntax/parser/TestParserSupport.java b/src/test/org/codehaus/groovy/syntax/parser/TestParserSupport.java
index 0f3f6d3..c1fa1f7 100644
--- a/src/test/org/codehaus/groovy/syntax/parser/TestParserSupport.java
+++ b/src/test/org/codehaus/groovy/syntax/parser/TestParserSupport.java
@@ -20,19 +20,19 @@ package org.codehaus.groovy.syntax.parser;
 
 import groovy.test.GroovyTestCase;
 import org.codehaus.groovy.ast.ModuleNode;
+import org.codehaus.groovy.control.CompilationUnit;
+import org.codehaus.groovy.control.Phases;
 import org.codehaus.groovy.control.SourceUnit;
 
-
 /**
  * An abstract base class useful for AST parser related test cases
  */
 public abstract class TestParserSupport extends GroovyTestCase {
-
-    public ModuleNode parse(String text, String description) throws Exception {
+    public ModuleNode parse(String text, String description) {
         SourceUnit unit = SourceUnit.create(description, text);
-        unit.parse();
-        unit.convert();
-
+        CompilationUnit compUnit = new CompilationUnit();
+        compUnit.addSource(unit);
+        compUnit.compile(Phases.CONVERSION);
         return unit.getAST();
     }
 }


[groovy] 01/02: GROOVY-9194: Groovy fails when a script starts with a #

Posted by pa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 64c94a28a80b6b008027fb1f6d553f6ba289fd7a
Author: Paul King <pa...@asert.com.au>
AuthorDate: Tue Apr 7 13:18:48 2020 +1000

    GROOVY-9194: Groovy fails when a script starts with a #
---
 src/main/java/org/codehaus/groovy/ast/ModuleNode.java | 6 +++---
 src/test/org/codehaus/groovy/ast/ModuleNodeTest.java  | 9 ++++++++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/ast/ModuleNode.java b/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
index 4e1376e..f305aea 100644
--- a/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
+++ b/src/main/java/org/codehaus/groovy/ast/ModuleNode.java
@@ -408,12 +408,12 @@ public class ModuleNode extends ASTNode implements Opcodes {
             URI uri = new URI(answer);
             String path = uri.getPath();
             String schemeSpecific = uri.getSchemeSpecificPart();
-            if (path!=null) {
+            if (path != null && !path.isEmpty()) {
                 answer = path;
-            } else if (schemeSpecific!=null) {
+            } else if (schemeSpecific != null && !schemeSpecific.isEmpty()) {
                 answer = schemeSpecific;
             }
-        } catch (URISyntaxException e) {}
+        } catch (URISyntaxException ignore) {}
         // let's strip off everything after the last '.'
         int slashIdx = answer.lastIndexOf('/');
         int separatorIdx = answer.lastIndexOf(File.separatorChar);
diff --git a/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java b/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
index 64aa295..d816156 100644
--- a/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
+++ b/src/test/org/codehaus/groovy/ast/ModuleNodeTest.java
@@ -38,7 +38,14 @@ public class ModuleNodeTest extends TestParserSupport {
         assertEquals("Number of classes", 1, classes.size());
 
         ClassNode classNode = (ClassNode) classes.get(0);
-
         assertEquals("Class name", "Cheese", classNode.getName());
     }
+
+    // GROOVY-9194
+    public void testScriptStartingWithHash() {
+        ModuleNode mn = new ModuleNode((CompileUnit) null);
+        mn.setDescription("#script.groovy");
+        ClassNode cn = mn.getScriptClassDummy();
+        assertEquals("Dummy class name should not be empty", "#script", cn.getName());
+    }
 }