You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/01/05 15:27:59 UTC
groovy git commit: Add a test case for code block
Repository: groovy
Updated Branches:
refs/heads/parrot 0e632683c -> 88d46080d
Add a test case for code block
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/88d46080
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/88d46080
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/88d46080
Branch: refs/heads/parrot
Commit: 88d46080da06f536ca24c26c488fc33f9e72e617
Parents: 0e63268
Author: Daniel Sun <su...@apache.org>
Authored: Thu Jan 5 23:27:45 2017 +0800
Committer: Daniel Sun <su...@apache.org>
Committed: Thu Jan 5 23:27:45 2017 +0800
----------------------------------------------------------------------
.../parser/antlr4/GroovyParserTest.groovy | 4 ++++
.../test/resources/core/CodeBlock_01x.groovy | 24 ++++++++++++++++++++
2 files changed, 28 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/88d46080/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy b/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
index cc657c4..e0f833a 100644
--- a/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
+++ b/subprojects/groovy-parser-antlr4/src/test/groovy/org/apache/groovy/parser/antlr4/GroovyParserTest.groovy
@@ -213,6 +213,10 @@ class GroovyParserTest extends GroovyTestCase {
doRunAndTest('core/While_02x.groovy');
}
+ void "test groovy core - CodeBlock"() {
+ doRunAndTest('core/CodeBlock_01x.groovy');
+ }
+
void "test groovy core - DoWhile"() {
doRunAndTest('core/DoWhile_01x.groovy');
doRunAndTest('core/DoWhile_02x.groovy');
http://git-wip-us.apache.org/repos/asf/groovy/blob/88d46080/subprojects/groovy-parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy b/subprojects/groovy-parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
new file mode 100644
index 0000000..d97e372
--- /dev/null
+++ b/subprojects/groovy-parser-antlr4/src/test/resources/core/CodeBlock_01x.groovy
@@ -0,0 +1,24 @@
+def m() {
+ int result = 0;
+ {
+ int i = 1;
+ result += i;
+ }
+ {
+ int i = 2;
+ result += i;
+
+ {
+ int j = 3;
+ result += j;
+ }
+ {
+ int j = 4;
+ result += j;
+ }
+
+ }
+ return { result }
+}
+
+assert m()() == 10
\ No newline at end of file