http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_01.groovy new file mode 100644 index 0000000..a6188c4 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_01.groovy @@ -0,0 +1,14 @@ +a 1 +a 1, 2 +a x: 1, y: 2 +a.b 1, 2 +z.a b(1), c(2) +a.b x: 1, y: 2 +z.a x: b(1), y: c(2) +a b(1), c(2) +a x: b(1), y: c(2) +z.a x: b(1, 3), y: c(2, 4) +a b(1, 3), c(2, 4) +obj.<Integer, Double>a b(1, 3), c(2, 4), d(3, 5) +println a +println a = 1 \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_02.groovy new file mode 100644 index 0000000..49da45a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_02.groovy @@ -0,0 +1,11 @@ +x y +x y a b +x y a.b +x y a +a b c() d e +a b c()() d e +a b c[x] d e +a b c[x][y] d e +a b c {x} d e +(1 + 2).plus 3 plus 4 +[1, 2].subList 0, 1 plus 2 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_03.groovy new file mode 100644 index 0000000..ed636d9 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_03.groovy @@ -0,0 +1,66 @@ +println withPool { +} + +println aa("bb", "cc") { +} + +println this.aa("bb", "cc") { +} + +println aa("bb", {println 123;}, "cc") { +} + +aa("bb", "cc") { + println 1 +} { println 2 } + +cc { + println 1 +} { + println 2 +} + +dd { + println 3 +} + +obj.cc { + println 1 +} { + println 2 +} + +bb 1, 2, {println 123;} + +obj."some method" (groovy.xml.dom.DOMCategory) { +} + +obj."some ${'method'}" (groovy.xml.dom.DOMCategory) { +} +obj.someMethod (groovy.xml.dom.DOMCategory) { +} + +use (groovy.xml.dom.DOMCategory) { +} + +['a','b','c'].inject('x') { + result, item -> item + result + item +} + +println a."${hello}"('world') { +} + +println a."${"$hello"}"('world') { +} + +a."${"$hello"}" 'world', { +} + +a.<String, Object>someMethod 'hello', 'world'; + +a[x] b +a[x] b c +a[x] b c d + +"$x"(1, 2) a +"$x" 1, 2 a http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_04.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_04.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_04.groovy new file mode 100644 index 0000000..2787686 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_04.groovy @@ -0,0 +1,7 @@ +promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } +promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } someProperty +promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } 'someProperty' +promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } "someProperty" +promise = promise.then { it * 2 } then { it * 3 } then { it + 6 } "somePropert${'y'}" +result = [1, 2, 3].size().plus 1 plus 2 + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_05.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_05.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_05.groovy new file mode 100644 index 0000000..03fa641 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_05.groovy @@ -0,0 +1,59 @@ +((int) 1 / 2)(1, 2) {} {} (2, 3, 4) {} +(((int) 1 / 2))(1, 2) {} {} (2, 3, 4) {} +(m())() +((Integer)m())() + +((int) 1 / 2) 1, 2 {} {} (2, 3, 4) {} + +'m'() + /aa/() + $/bb/$() + "$m"() + /a${'x'}a/() + $/b${'x'}b/$() + 1.2('b') + 1('a') + 2() + null() + true() + false() + a() + {a,b->}(1, 2) + [1, 2]() + [a:1, b:2]() + new int[0]() + new Integer(1)() + +// cast expressions +(int)(1 / 2) +(Integer)(1 / 2) +(java.lang.Integer)(1 / 2) + + + +1 + 1.("a" + "1")() +1 + 1.(m())() +1.("a" + "1")() +1.("a" + "1")(123) +1.("a" + "1") 123 +1.(m())() +1.(m())(123) +1.(m()) 123 +(1+1).("a"+1)() +(1+1).("a"+1) a b c +1+1.("a"+1)() + +x = a(1, 2)(3, 4) {} {} (5, 6) {} (7, 8) +x = a(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {} {} +x = obj.a(1, 2)(3, 4) {} {} (5, 6) {} (7, 8) +x = obj.a(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {} {} +x = {a, b -> }(1, 2)(3, 4) {} {} (5, 6) {} (7, 8) +x = {a, b -> }(1, 2) {} (3, 4) {} {} (5, 6) {} (7, 8) {} +x = {a, b -> }(1, 2) {} {} (3, 4) {} {} (5, 6) {} (7, 8) {} {} + + + +m 1, 2 +"m" 1, 2 +"$m" 1, 2 + +("m") 1, 2 +("$m") 1, 2 + +find x: + 1 confirm right + + +find x: + 1, + y: + 2 confirm right + +a b 1 2 + + +(obj.m1(1, 2)) m2(3, 4) +obj.m1(1, 2) m2(3, 4) http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_06x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_06x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_06x.groovy new file mode 100644 index 0000000..a6bcadf --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Command_06x.groovy @@ -0,0 +1,8 @@ +assert 11 == (1.plus 2 plus 3) + (2.plus 3) * (1.multiply 1) - ((1 - 1).intdiv 1 multiply 1) / (2.power 10) +assert (Long)(1.plus 2 plus 3) instanceof Long +assert [1, 2, 3] == [(1.plus 0), (1.plus 1), (1.plus 1 plus 1)] + +def m(a, b) { + return a + b +} +assert m((1.plus 2 plus 3), (1.multiply 1)) == 7 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_01.groovy new file mode 100644 index 0000000..c38c6fb --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_01.groovy @@ -0,0 +1,28 @@ +#!/usr/bin/env groovy +/* + * 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. + */ + +/** + * Created by Daniel.Sun on 2016/08/16. + */ + +// this is a line comment + +println /* method name */ 1 /* one */ /* followed by plus */ + /* plus */ 2 /* two */ ++3 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_02.groovy new file mode 100644 index 0000000..f994c35 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Comments_02.groovy @@ -0,0 +1,107 @@ +/** + * test class Comments + */ +public class Comments { + /** + * test Comments.SOME_VAR + */ + public static final String SOME_VAR = 'SOME_VAR'; + /** + * test Comments.SOME_VAR2 + */ + public static final String SOME_VAR2 = 'SOME_VAR2'; + + public static final String SOME_VAR3 = 'SOME_VAR3'; + + /** + * test Comments.SOME_VAR4 + */ + // no groovydoc for SOME_VAR4 + public static final String SOME_VAR4 = 'SOME_VAR4'; + + + /** + * test Comments.constructor1 + */ + public Comments() { + + } + + /** + * test Comments.m1 + */ + def m1() { + // executing m1 + } + + /* + * test Comments.m2 + */ + private m2() { + // executing m2 + } + + /** + * test Comments.m3 + */ + public void m3() { + // executing m3 + } + + /** + * test class InnerClazz + */ + static class InnerClazz { + /** + * test InnerClazz.SOME_VAR3 + */ + public static final String SOME_VAR3 = 'SOME_VAR3'; + /** + * test InnerClazz.SOME_VAR4 + */ + public static final String SOME_VAR4 = 'SOME_VAR4'; + + /** + * test Comments.m4 + */ + public void m4() { + // executing m4 + } + + /** + * test Comments.m5 + */ + public void m5() { + // executing m5 + } + } + + /** + * test class InnerEnum + */ + static enum InnerEnum { + /** + * InnerEnum.NEW + */ + NEW, + + /** + * InnerEnum.OLD + */ + OLD + } + + static enum InnerEnum2 {} +} + +/** + * test class Comments2 + */ +class Comments2 { + /* + * test Comments.SOME_VAR + */ + public static final String SOME_VAR = 'SOME_VAR'; +} + +class Comments3 {} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_01x.groovy new file mode 100644 index 0000000..a56c7ee --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_01x.groovy @@ -0,0 +1,7 @@ +int i = 0; + +do { + i++ +} while (i < 5) + +assert i == 5 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_02x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_02x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_02x.groovy new file mode 100644 index 0000000..31f6264 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_02x.groovy @@ -0,0 +1,8 @@ +int i = 0; + +do { + i++ + if (i == 3) break; +} while (i < 5) + +assert i == 3 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_03x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_03x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_03x.groovy new file mode 100644 index 0000000..46c32ff --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_03x.groovy @@ -0,0 +1,11 @@ +int i, j = 0; + +do { + i++ + if (i == 4) break; + + if (j == 3) continue; + j++ +} while (true) + +assert j == 3 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_04x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_04x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_04x.groovy new file mode 100644 index 0000000..5863ca9 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/DoWhile_04x.groovy @@ -0,0 +1,14 @@ +import groovy.transform.CompileStatic + +@CompileStatic +def a() { + int i = 0; + int result = 0; + do { + result += 2 + } while(i++ < 2) + result += 3 + + return result; +} +assert 9 == a() \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_01.groovy new file mode 100644 index 0000000..c4a43c8 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_01.groovy @@ -0,0 +1,44 @@ +enum AAAA {} +public enum AAAA2 {} +public enum AAAA3 implements A {} +@Test2 +public enum AAAA4 implements A,B {} +enum BBBB {A} +enum CCCC {A, B} +enum DDDD {A, B,} +enum EEEE { + A, + B} +enum FFFF { + A, + B,} +enum GGGG +{A, +B,} + +enum E1 { + A(111,'aa'), B(222,'bb') +} + +@Test2 +enum E2 { + A2, + B2,C2, + D2 + private void a() {} + def c; +} + +enum E3 { + A(1), B(2) + + public static final String SOME_CONSTANT = '123'; + private String name; + private int age = 2; + String title = "title" + public E9(int x) {} +} + + + +enum e {} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_02.groovy new file mode 100644 index 0000000..872c5ee --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_02.groovy @@ -0,0 +1,52 @@ +enum E { + A() {}, B(1) {{}}, + C(1, 2) { + public void prt() { + println "$x, $y" + } + + void prt2() { + println "$x, $y" + } + + @Test2 prt3() { + println "$x, $y" + } + + private void prt4() { + println "$x, $y" + } + + private prt5() { + println "$x, $y" + } + }, + D { + void hello() {} + } + + protected int x; + protected int y; + + E() {} + E(int x) { + this.x = x; + } + E(int x, y) { + this(x) + this.y = y; + } + + void prt() { + println "123" + } +} + +enum F { + @Test2 + A +} + +enum G implements I<T> { + +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_03.groovy new file mode 100644 index 0000000..431a9e3 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/EnumDeclaration_03.groovy @@ -0,0 +1,6 @@ +enum H { + SOME_ENUM_CONSTANT0(a: "0"), + SOME_ENUM_CONSTANT1(a: "0") {}, + SOME_ENUM_CONSTANT2(a: "1", b: "2"), + SOME_ENUM_CONSTANT3(c: "3", d: "4") {} +} http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_01.groovy new file mode 100644 index 0000000..e27fbbc --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_01.groovy @@ -0,0 +1,230 @@ +-1 +-12 +-123 + +-1.2 +-1.2f +-1.2F +-1.2d +-1.2D +-1.2g +-1.2G + +-0x1234567890abcdef +-0X1234567890ABCDEF +-0x1234567890abcdefi +-0x1234567890abcdefl +-0x1234567890abcdefg +-0x1234567890abcdefI +-0x1234567890abcdefL +-0x1234567890abcdefG +-0xabcdef +-0xABCDEF +-0xABCDEF +-0xabcdef +-0xABCDEF + +-01234567 +-01234567 +-01234567 +-01234567i +-01234567l +-01234567g +-01234567I +-01234567L +-01234567G + +-1__2 +-2_12_3 +-2__12__3 +-2__12__3.1__2 +-2__12__3.1__2 +-12e10 +-12e-10 +-12e10 +-12e-10 +-12.12e10 +-12.12e-10 +-12.12e10 +-12.12e-10 +-12.12e-10f +-12.12e-10d +-12.12e-10g +-12e-10F +-120e-10D +-11F +-12D +-1.1F +-1.2D +-12e-10G +-12.1__2e-10f +-12.1_2e-10d +-1__12_2.12e-10g +-0xab__cdef +-0xAB__CD_EF +-012__34567L + +-0b010101 +-0B10101011 + ++1 ++12 ++123 + ++1.2 ++1.2f ++1.2F ++1.2d ++1.2D ++1.2g ++1.2G + ++0x1234567890abcdef ++0X1234567890ABCDEF ++0x1234567890abcdefi ++0x1234567890abcdefl ++0x1234567890abcdefg ++0x1234567890abcdefI ++0x1234567890abcdefL ++0x1234567890abcdefG ++0xabcdef ++0xABCDEF ++0xABCDEF ++0xabcdef ++0xABCDEF + ++01234567 ++01234567 ++01234567 ++01234567i ++01234567l ++01234567g ++01234567I ++01234567L ++01234567G + ++1__2 ++2_12_3 ++2__12__3 ++2__12__3.1__2 ++2__12__3.1__2 ++12e10 ++12e-10 ++12e10 ++12e-10 ++12.12e10 ++12.12e-10 ++12.12e10 ++12.12e-10 ++12.12e-10f ++12.12e-10d ++12.12e-10g ++12e-10F ++120e-10D ++11F ++12D ++1.1F ++1.2D ++12e-10G ++12.1__2e-10f ++12.1_2e-10d ++1__12_2.12e-10g ++0xab__cdef ++0xAB__CD_EF ++012__34567L + ++0b010101 ++0B10101011 + +~1 +~12 +~123 + +~1.2 +~1.2f +~1.2F +~1.2d +~1.2D +~1.2g +~1.2G + +~0x1234567890abcdef +~0X1234567890ABCDEF +~0x1234567890abcdefi +~0x1234567890abcdefl +~0x1234567890abcdefg +~0x1234567890abcdefI +~0x1234567890abcdefL +~0x1234567890abcdefG +~0xabcdef +~0xABCDEF +~0xABCDEF +~0xabcdef +~0xABCDEF + +~01234567 +~01234567 +~01234567 +~01234567i +~01234567l +~01234567g +~01234567I +~01234567L +~01234567G + +~1__2 +~2_12_3 +~2__12__3 +~2__12__3.1__2 +~2__12__3.1__2 +~12e10 +~12e-10 +~12e10 +~12e-10 +~12.12e10 +~12.12e-10 +~12.12e10 +~12.12e-10 +~12.12e-10f +~12.12e-10d +~12.12e-10g +~12e-10F +~120e-10D +~11F +~12D +~1.1F +~1.2D +~12e-10G +~12.1__2e-10f +~12.1_2e-10d +~1__12_2.12e-10g +~0xab__cdef +~0xAB__CD_EF +~012__34567L + +~0b010101 +~0B10101011 + +!true +!false + ++a +-a + +++a +--a + +int[] +String[] +String[][] + + +1 +2147483647 +2147483648 +9223372036854775807 +9223372036854775808 +-1 +-2147483648 +-2147483649 +-9223372036854775808 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_02.groovy new file mode 100644 index 0000000..6c16438 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_02.groovy @@ -0,0 +1,6 @@ +assert (1) +assert ( + 1) +assert ( + 1 +) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_03.groovy new file mode 100644 index 0000000..4e570a3 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_03.groovy @@ -0,0 +1,31 @@ +1 + 2 + 3 +'a' + 'b' + 'c' +10 - 2 + 3 - 5 + 6 + 7 +++a + 1 - --b - 6 + ++c + 'a' + 2 - 3 +++a + + 1 - + --b - + 6 + + ++c + + 'a' + + 2 * + 3 + + a++ - + a-- + +1 * 2 / 3 % 4 +1 * + 2 / + 3 % + 4 + + +1 ** 2 ** 3 +1 ** + 2 ** + 3 + +1 + 2 * 3 - 4 / 5 + 6 % 7 - 8 ** 9 + + + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_04.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_04.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_04.groovy new file mode 100644 index 0000000..de7c2df --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_04.groovy @@ -0,0 +1,62 @@ +a = 1 +a = b = 1 +left >>>= 16 +left >>= 8 +left <<= 2 +sum += sup +cantlive -= you +times *= me +times **= me +slash /= nstore +your |= me +here %= sometimes +water ^= oil +a &= that + +a = e f g h +a = b *= c += d %= e f g h + +obj.name = '123' +m().result = 123 +map[a] = 1 +map['a'] = 1 +map["$a"] = 1 +map[a.b] = 1 +map[a()] = 1 +map[obj.a()] = 1 +map[a().result] = 1 +map[a + b] = 1 +obj.prop[0][1] = 'a' +this = someValue; +super = someValue; + +list[0] = 1 +list[1, 2] = [11, 22] + +(a) = [1] +(a) = x++ +(a) = (SomeType)x++ +(a) = obj.m() +(a) = [1] +(a) = [1] + [2] +(a, b) = [1, 2] +(a, b, c) = [1, 2, 3] + +(obj) = + a = + b = + left >>>= + left >>= + left <<= + sum += + cantlive -= + times *= + times **= + slash /= + your |= + here %= + water ^= + a &= + that = + x y z + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_05.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_05.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_05.groovy new file mode 100644 index 0000000..20a8590 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_05.groovy @@ -0,0 +1,40 @@ +true ?: 'a' + +true +?: 'a' + +true +?: +'a' + +true ? 'a' : 'b' + +true ? + 'a' + : + 'b' + +true ? + 'a' + : + true ?: 'b' + +true ? + 'a' + : + true ? 'b' : 'c' + +true ?: true ?: 'a' + +1 == 2 ?: 3 +1 == 2 ? 3 : 4 + +1 == 2 || 1 != 3 && !(1 == 6) + ? 2 > 3 && 3 >= 1 + ? 4 < 5 && 2 <= 9 ?: 6 ^ 8 | 9 & 10 + : 8 * 2 / (3 % 4 + 6) - 2 + : 9 + + +bar = 0 ? "moo" \ + : "cow" http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_06.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_06.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_06.groovy new file mode 100644 index 0000000..6d8657d --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_06.groovy @@ -0,0 +1,6 @@ +true && false || true && false || true +true && + false || + true && + false || + true http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_07.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_07.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_07.groovy new file mode 100644 index 0000000..428b385 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_07.groovy @@ -0,0 +1,9 @@ +1 | 2 ^ 3 & 4 | 5 ^ 6 & 7 | 8 +1 | + 2 ^ + 3 & + 4 | + 5 ^ + 6 & + 7 | + 8 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_08.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_08.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_08.groovy new file mode 100644 index 0000000..bce3db2 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_08.groovy @@ -0,0 +1,6 @@ +a =~ /abc/ +a =~ + /abc/ +b ==~ /abc/ +b ==~ + /abc/ http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_09.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_09.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_09.groovy new file mode 100644 index 0000000..26f161b --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_09.groovy @@ -0,0 +1,16 @@ +1 == 1 != 2 == 3 != 4 <=> 5 == 6 != 7 +1 == + 1 != + 2 == + 3 != + 4 <=> + 5 == + 6 != + 7 +2 == 3 != 4 <=> 5 + + + 2 == + 3 != + 4 <=> + 5 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_10.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_10.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_10.groovy new file mode 100644 index 0000000..7d3fea2 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_10.groovy @@ -0,0 +1,25 @@ +1 < 2 +1 < + 2 +2 <= 2 +2 <= + 2 +2 >= 2 +2 >= + 2 +2 > 1 +2 > + 1 +1 in [1, 2, 3] +1 in + [1, 2, 3] + +'abc' instanceof String +'abc' instanceof + String +'abc' as String +'abc' as + String + + +1 < 2 && 2 <= 2 | 2 >= 2 && (2 > 1 || 1 == 1) & (1 != 2 || 1 ^ 2 && 1 <=> 2) && 1 in [1, 2, 3] && 'abc' as String || 'abc' instanceof String \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_11.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_11.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_11.groovy new file mode 100644 index 0000000..4ee3e30 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_11.groovy @@ -0,0 +1,16 @@ +1 << 2 +1 << + 2 +1 >> 2 +1 >> + 2 +1 >>> 3 +1 >>> + 3 + +1..2 +1.. + 2 +1..<2 +1..< + 2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_12.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_12.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_12.groovy new file mode 100644 index 0000000..5b56a8a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_12.groovy @@ -0,0 +1,17 @@ +!true +! + true +~1 +~ + 1 +(String)'abc' +(int) obj.someMethod() +(int) (obj.someMethod()) +(int) 1 / 2 +1 / (int) 2 +(int) a++ +(int) a-- +(int) ++a +(int) --a +(int) ~123 +(boolean) !false \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_13.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_13.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_13.groovy new file mode 100644 index 0000000..dcf930b --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_13.groovy @@ -0,0 +1,45 @@ +!5 +~5 +-5 ++5 +-a ++a + +5+5 ++(+5) +-(-5) ++(-5) +-(+5) + +5 + 10 +5 - 10 +5 * 10 +5 / 10 +5 % 10 +5 ** 10 + +5-- +5++ +--5 +++5 + +5 >> 10 +5 >>> 10 +5 << 10 +5 > 10 +5 < 10 + +5 ^ 10 + +5 | 10 +5 & 10 + +5 || 10 +5 && 10 +5 == 10 +5 != 10 +5 <=> 10 + +5..10 +5..10 +5..<10 > 1..3 http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_14.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_14.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_14.groovy new file mode 100644 index 0000000..4d7d85d --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_14.groovy @@ -0,0 +1,22 @@ +a = java.lang.Integer +a = java.lang.Integer.class +a = Integer +a = Integer.class +a = void +a = void.class +a = boolean +a = boolean.class +a = byte +a = byte.class +a = char +a = char.class +a = short +a = short.class +a = int +a = int.class +a = float +a = float.class +a = long +a = long.class +a = double +a = double.class \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_15.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_15.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_15.groovy new file mode 100644 index 0000000..8e2978e --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_15.groovy @@ -0,0 +1,127 @@ +person.@name +person.child.@name +person.@name.count +person.&sayHello +person.child.&sayHello +person?.child +person?.@child +person*.child +person*.@child +person.'name' +person.@'name' +person?.'name' +person?.@'name' +person*.'child' +person*.@'child' +person.&'sayHello' +person.new +person.@new +person?.new +person?.@new +person*.new +person*.@new +person.&new +person."$name" +person.@"$name" +person?."$name" +person?.@"$name" +person*."$name" +person*.@"$name" +person.&"$methodName" +person.("$firstname" + "$lastname") +person.@("$firstname" + "$lastname") +person?.("$firstname" + "$lastname") +person?.@("$firstname" + "$lastname") +person*.("$firstname" + "$lastname") +person*.@("$firstname" + "$lastname") +person.&("$method" + "$name") + +a.b?.c[1, 2, 3]*.d +a[1, *[2, 3]]*.b +a[*[2, 3]]*.b + +person +*. +child +*. +@child +?. +child +?. +@child +. +child + . +@name +.& +length + +a.b() +a.'b'() +a."$b"() +a?.b() +a*.b() +a() +'a'() +"$a"() + +obj.a + .b() + ?.c() + *.d() + +obj.a(1, 2) +a(1, 2) + +obj.a(x: 1, y: 2) +a(x: 1, y: 2) + +a.@b() +a.@b(1, 2, 3) +a?.@b() +a?.@b(1, 2, 3) +a*.@b() +a*.@b(1, 2, 3) + +a.<Integer>b(1, 2) + +a + . +<Integer>b(1, 2) + +a.<Integer, String>b(1, '2') +a?.<Integer, String>b(1, '2') +a*.<Integer, String>b(1, '2') +obj?.a*.< + Integer, + String + >b(1, '2') + +String[] codes = [ + className + '.' + propertyName + '.typeMismatch.error', + className + '.' + propertyName + '.typeMismatch', + classAsPropertyName + '.' + propertyName + '.typeMismatch.error', + classAsPropertyName + '.' + propertyName + '.typeMismatch', + bindingResult.resolveMessageCodes('typeMismatch', propertyName) +].flatten() as String[] + + +person*.child[1, 2 + 6, *[3, 4]]*.@child*.@child()?.@child().@child()?.child?.@child.child.getChild().getChild(1, 2).getChild(name: 'a', age: 2).'child'."$child".('chi' + 'ld').@name.class.&equals + + +(obj.x)() +(obj.@x)() + + +static.unused = { -> } + +ResolveOptions resolveOptions = new ResolveOptions()\ + .setConfs(['default'] as String[])\ + .setOutputReport(false)\ + .setValidate(args.containsKey('validate') ? args.validate : false) + +new A("b") C.d() + +m()() + +a = {a,b-> }() http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_16.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_16.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_16.groovy new file mode 100644 index 0000000..88a2926 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_16.groovy @@ -0,0 +1,22 @@ +this +super +this.name +super.name + + +def x = {->}() +x = {a, b -> a + b }(1, 2) + +void() +void(1, 2) +void(1, 2) { + +} +void(x: 1, y: 2) +void(x: 1, y: 2) { + +} + +use(String) { +} + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_17.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_17.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_17.groovy new file mode 100644 index 0000000..7dcf79e --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_17.groovy @@ -0,0 +1,141 @@ +a.m(x: 1, y: 2) { + println('named arguments'); +} + +a.m(x: 1, y: 2, z: 3) { + println('named arguments'); +} { + println('named arguments'); +} + + +a.m(x: 1, y: 2, z: 3) + +{ + println('named arguments'); +} + +{ + println('named arguments'); +} + + + +a.m(1, 2) { + println('normal arguments'); +} + +a.m(1, 2, 3) { + println('normal arguments'); +} { + println('normal arguments'); +} + +a.m(1, 2, 3) + +{ + println('normal arguments'); +} + + +{ + println('normal arguments'); +} + + + + +m { + println('closure arguments'); +} + +m { + println('closure arguments'); +} { + println('closure arguments'); +} + +m { + println('closure arguments'); +} { + println('closure arguments'); +} { + println('closure arguments'); +} + + +m + +{ + println('closure arguments'); +} + +{ + println('closure arguments'); +} + +{ + println('closure arguments'); +} + +'m' { + println('closure arguments'); +} + + +1 { + +} +1.1 { + +} + +-1 { + +} + +-1.1 { + +} + +1() +1.1() +1(1, 2, 3) +1.1(1, 2, 3) +-1() +-1.1() +-1(1, 2, 3) +-1.1(1, 2, 3) + +1(1, 2) { + +} + +1.1(1, 2) { + +} + +-1(1, 2) { + +} + +-1.1(1, 2) { + +} + +hello(x: 1, y: 2, z: 3) +hello('a', 'b') +hello(x: 1, 'a', y: 2, 'b', z: 3) +hello('c', x: 1, 'a', y: 2, 'b', z: 3) + + +A[x: 1, y: 2] +A[*: someMap] +A[*: someMap, z: 3] +A[w: 0, *: someMap] +A[*: [x: 1, y: 2]] +A[*: [x: 1, y: 2], z: 3] +A[w: 0, *: [x: 1, y: 2]] + +SomeMethod(a, b) + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_18.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_18.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_18.groovy new file mode 100644 index 0000000..2b81194 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_18.groovy @@ -0,0 +1,26 @@ +1 > 2 ? 'y' : 'n' +1 >= 2 ? 'y' : 'n' +1 < 2 ? 'y' : 'n' +1 <= 2 ? 'y' : 'n' +1 == 2 ? 'y' : 'n' +1 != 2 ? 'y' : 'n' + +p29 = 1 > 2 ? /ab/ : /cd/ +p30=++a == b[2].next() +p31=a <=> b == a.compareTo(b) +p32 = 1 in [1, 2, 3] == 1 instanceof Integer +p33 = 1-2+3 +p34 = 1+2-3 +p35 = 1*2/3 +p36 = 1/2*3 +p37 = 1*2%3 +p38 = 1%2*3 +p39 = 1/2%3 +p40 = 1%2/3 +p41 = 1+2+3 +p42 = 1-2-3 +p43 = 1*2*3 +p44 = 1/2/3 +p45 = 1%2%3 +p46 = 1-2*3+4/5-6%7-8-9+10/11*12-13+14+15-16%17%18/19/20*21*22 + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_19.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_19.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_19.groovy new file mode 100644 index 0000000..95d519f --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_19.groovy @@ -0,0 +1,32 @@ +List list = new ArrayList(); +List list2 = new java.util.ArrayList(); +List<String> list3 = new ArrayList<String>(); +List<String> list4 = new java.util.ArrayList<String>(); +List<String> list5 = new ArrayList<>(); +//List<String> list6 = new java.util.ArrayList<>(); // the old parser can not parse "new java.util.ArrayList<>()" +def x = new A<EE, TT>(); +int[] a = new int[10]; +int[][] b = new int[length()][2 * 8]; +ArrayList[] c = new ArrayList[10]; +ArrayList[][] cc = new ArrayList[10][size()]; +java.util.ArrayList[] d = new java.util.ArrayList[10]; +ArrayList[] e = new ArrayList<String>[10]; +java.util.ArrayList[] f = new java.util.ArrayList<String>[10]; +java.util.ArrayList[] g = new java.util.ArrayList<String>[size()]; + +int[][] h = new int[10][]; +int[][][] i = new int[10][][]; +ArrayList[][] j = new ArrayList[10][]; +ArrayList[][] k = new ArrayList<String>[10][]; + +def bb = new A.B(); +def bb2 = new A.B[0]; + +new + A + ('x', 'y'); + + +new a(); +new $a(); +new as.def.in.trait.a(); http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_20.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_20.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_20.groovy new file mode 100644 index 0000000..9070b06 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_20.groovy @@ -0,0 +1,2 @@ +@Test2(pre={ super(xx);}) +class XX {} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_21x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_21x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_21x.groovy new file mode 100644 index 0000000..506ccb8 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Expression_21x.groovy @@ -0,0 +1,6 @@ +new int[5] +new int[5][] +new int[5][6][] +new int[5][6][7][] +new int[5][6][7][][] +new int[5][6][7][][][] http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_01.groovy new file mode 100644 index 0000000..53c4911 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_01.groovy @@ -0,0 +1,55 @@ +for (i in someList) {} + + +for (i in someList) { + break; +} + +for (i in someList) +{ + break; +} + +for (int i in someList) { + break; +} + +for (String i in someList) { + break; +} + +for (final String i in someList) { + break; +} + +for (@Test2 String i in someList) { + break; +} + + +for (int i : someList) {} + +for (int i : someList) { + break; +} + +for (int i : someList) +{ + break; +} + +for (int i : someList) { + break; +} + +for (String i : someList) { + break; +} + +for (final String i : someList) { + break; +} + +for (@Test2 String i : someList) { + break; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_02.groovy new file mode 100644 index 0000000..6979940 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_02.groovy @@ -0,0 +1,36 @@ +for (int i = 0; true; false) {} +for (int i = 0; true; false) { + +} +for (int i = 0; true; false) +{ +} +for (int i = 0; + true; + false) +{ +} +for(;;) { + +} +for(int i = 0;;) { + +} +for(;true;) { + +} +for(;;false) { + +} + +for (int i = 0; i < 10; i++) { + +} + +for (i = 0; i < 10; i++) { + +} + +for(;;) { + continue; +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_03.groovy new file mode 100644 index 0000000..f9ff466 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/For_03.groovy @@ -0,0 +1,37 @@ +outer: +for (def i in [1, 2]) { + for (def j in [1, 2, 3, 4, 5]) { + if (j == 1) { + break outer; + } else if (j == 2) { + continue outer; + } + + if (j == 3) { + continue; + } + + if (j == 4) { + break; + } + } +} + + +for (;;) + int number = 1 + + +int i +for (i = 0; i < 5; i++); + + + + +for (Object child in children()) { + if (child instanceof String) { + break + } else { + continue + } +} http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_01.groovy new file mode 100644 index 0000000..0d4e777 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_01.groovy @@ -0,0 +1,30 @@ +"abc${'123'}def" +"${'123'}def" +"${'123'}" +"a:$a" +"a:$a.b.c" +"$a.b.c" +"$a.b.c,d" +"${12}a${}c${34}" +"${->12}" +"${12}${->12}${'12'}" +"""abc${'123'}def""" +"""${'123'}def""" +"""${'123'}""" +"""a:$a""" +"""a:$a.b.c""" +"""$a.b.c""" +"""$a.b.c,d""" +"""${12}a${}c${34}""" +"""${->12}""" +"""${12}${->12}${'12'}""" +"""${12}${->12}${'12'}${a=1;return a;}""" + + +"${}" +"${;}" +"${;;}" +"${;;;}" + +"${a b}" +"${obj.a b}" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_02.groovy new file mode 100644 index 0000000..c27bfef --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_02.groovy @@ -0,0 +1,59 @@ +/abc${'123'}def $a.b.c,d${->12}/ +$/${-12}abc${'123'}def $a.b.c,d${->12}/$ + +def p1=/ab/ +def p2=/a${c}b/ +p3=/a${c}b/ +p4=/a${c}b/*2 +p5=!/a${c}b/ +p6= ~/a${c}b/ +p7=~/a${c}b/ +p8==~/a${c}b/ +p9=/a${c}b/ + /a${c}b/ +p10=/ab/ +p11=/ab/*2 +p12=!/ab/ +p13= ~/ab/ +p14=~/ab/ +p15==~/ab/ +p16=/ab/ + /ab/ +p17=/ab/ == /cd/ +p18=/a${c}b/ == /c${f}d/ +p19=/ab/ != /cd/ +p20=/a${c}b/ != /c${f}d/ +p27=1?:/cd/ +p28=1?:/a${c}b/ +p29=1>2?/ab/:/cd/ +p30=1>2?/c${f}d/:/c${f}d/ +p29=true? + /ab/: + /cd/ +p30=true? + /c${f}d/: + /c${f}d/ +p31=/A/ && /B/ +p32=/a${b}/ && /c${d}/ +p33=/A/ || /B/ +p34=/a${b}/ || /c${d}/ +p39=/$a/ +p40=/^a+$/ +p41=/$0+/ +p42=/$2a+/ +p43=/$$2a+/ +p44=/^$|$|^$$2a+$/ +p45=/ + hello, world! +/ +p46=/hello\ +world/ +p47=/hello\ + \/ +world/ +p48=/^hello\ + \/$|^ +world$/ +p49=/ $x $ / +p50=/$x\ + $ +/ +p51=/$$/ http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_03.groovy new file mode 100644 index 0000000..f535731 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/GString_03.groovy @@ -0,0 +1,49 @@ +def a = """hello${a} +world +""" + +a = """ +hello +${a} +world +""" + +a =~ $/(${123}hello) \/ + ${a}world\1 + \u9fa5 \r +/$ +a =~ $/\ + x $ + $$ + $/ +/$ +a =~ $/\ + $x $ + $$ + $/ +/$ +a = $/ + Hello name, + today we're date. + + $ dollar sign + $$ escaped dollar sign + \ backslash + / forward slash + $/ escaped forward slash + $/$ escaped dollar slashy string delimiter + /$ + +a = $/ + Hello $name, + today we're ${date}. + + $ dollar sign + $$ escaped dollar sign + \ backslash + / forward slash + $/ escaped forward slash + $/$ escaped dollar slashy string delimiter + /$ +a = $/$$VAR/$ +a = $/$$ $VAR/$ http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/IdenticalOp_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/IdenticalOp_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/IdenticalOp_01x.groovy new file mode 100644 index 0000000..bc8fff0 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/IdenticalOp_01x.groovy @@ -0,0 +1,10 @@ +def x = [] +def y = [] +assert y !== x + +assert 'a' === 'a' +assert 'a' !== new String('a') +assert null === null +assert true === true +assert false === false +assert 0 == 0 && 'a' === 'a' && 1 != 2 && 'a' !== new String('a') && 1 == 1 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/IfElse_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/IfElse_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/IfElse_01.groovy new file mode 100644 index 0000000..d58c302 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/IfElse_01.groovy @@ -0,0 +1,44 @@ +if (true) + assert true, ':(' + +if (true) assert true, ':(' + +if (true) + assert true, ':(' +else + assert false, ':(' + +if (true) assert true, ':(' +else + assert false, ':(' + +if (true) assert true, ':(' +else assert false, ':(' + +if (true) assert true, ':(' else assert false, ':(' + + +if (false) + int number = 1 + + +if(true) 1; else 0 + +if(true) 1 else 0 + +if(true) 1; else 0; + +if(true) + 1; +else + 0 + +if(true) + 1 +else + 0 + +if(true) + 1; +else + 0; http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_01.groovy new file mode 100644 index 0000000..2d8aaeb --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_01.groovy @@ -0,0 +1 @@ +import java.util.Map \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_02.groovy new file mode 100644 index 0000000..d420d29 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_02.groovy @@ -0,0 +1 @@ +import java.util.Map; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_03.groovy new file mode 100644 index 0000000..bbd6f42 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_03.groovy @@ -0,0 +1,4 @@ +import java.util.Map +import java.util.HashMap; +import java.io.InputStream +import java.io.BufferedInputStream; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_04.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_04.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_04.groovy new file mode 100644 index 0000000..c9e8698 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_04.groovy @@ -0,0 +1,5 @@ +package core; +import java.util.Map +import java.util.HashMap; +import java.io.InputStream +import java.io.BufferedInputStream; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_05.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_05.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_05.groovy new file mode 100644 index 0000000..9537b2d --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_05.groovy @@ -0,0 +1 @@ +import java.util.* \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_06.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_06.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_06.groovy new file mode 100644 index 0000000..ab53935 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_06.groovy @@ -0,0 +1,3 @@ +import java.util.* +import java.math.BigDecimal +import java.io.* \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_07.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_07.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_07.groovy new file mode 100644 index 0000000..5afff4e --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_07.groovy @@ -0,0 +1,6 @@ +package core; +import java.util.* +import java.math.BigDecimal; +import java.io.* +import static java.lang.Math.* +import static java.lang.Math.pow http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_08.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_08.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_08.groovy new file mode 100644 index 0000000..b2ed424 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/ImportDeclaration_08.groovy @@ -0,0 +1,28 @@ +#!/usr/bin/env groovy +/* + * 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. + */ +package core; + +import java.util.* +import java.math.BigDecimal; +import java.io.* +import java.sql.Blob as Bb +import static java.lang.Math.*; +import static java.lang.Math.pow as pw +import def.in.as.trait.*; http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_01.groovy new file mode 100644 index 0000000..7ad0fa7 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_01.groovy @@ -0,0 +1,36 @@ +package core + +interface A1 {} +interface A2<T> {} +interface A3<T extends A> {} +interface A4<T extends A & B> {} +interface A5<T extends A & B & C> {} +interface A6<T extends A & B & C> extends A {} +interface A62 extends A<T> {} +interface A7<T extends A & B & C> extends A, B {} +interface A8<T extends A & B & C> extends A, B, C {} +@Test2 interface A9<T extends A & B & C> extends A, B, C {} +@Test2 @Test3 public interface A10<T extends A & B & C> extends A, B, C {} + +@Test2 +@Test3 +@Test4 +public +interface A11 +< + T extends +A & +B & +C +> +extends +A, +B, +C + { + + } + +interface Iterator extends java.util.Iterator {} + +interface i {} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_02.groovy new file mode 100644 index 0000000..6305e5a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_02.groovy @@ -0,0 +1,42 @@ +package core + +import java.sql.SQLException + +public interface AA1 { + int a; + long b; + double c; + char d; + short e; + byte f; + float g; + boolean h; + String i; + + public static final NAME = "AA1" + + @Test3 + public static final NAME2 = "AA1" + + void sayHello(); + abstract void sayHello2(); + public void sayHello3(); + public abstract void sayHello4(); + @Test2 + public abstract void sayHello5(); + + @Test2 + public abstract void sayHello6() throws IOException, SQLException; + + @Test2 + @Test3 + public abstract <T> T sayHello7() throws IOException, SQLException; + + @Test2 + @Test3 + public abstract <T extends A> T sayHello8() throws IOException, SQLException; + + @Test2 + @Test3 + public abstract <T extends A & B> T sayHello9() throws IOException, SQLException; +} http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_03.groovy new file mode 100644 index 0000000..4d555db --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/InterfaceDeclaration_03.groovy @@ -0,0 +1,7 @@ +interface Koo { + class Inner {} +} + +interface Koo2 { + public static final Inner INNER = new Inner() {} +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Label_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Label_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Label_01.groovy new file mode 100644 index 0000000..dfefa51 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Label_01.groovy @@ -0,0 +1,15 @@ +a: assert true; +a: assert true +a: +assert true; +a: +assert true + + +before: +setup: +int a = 1 +int b = 1 +expect: +a == b + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Lambda_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Lambda_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Lambda_01x.groovy new file mode 100644 index 0000000..a1400a3 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Lambda_01x.groovy @@ -0,0 +1,47 @@ +assert 9 == [1, 2, 3].stream().map(e -> e + 1).reduce(0, (r, e) -> r + e) +assert 9 == [1, 2, 3].stream().map(e -> {e + 1}).reduce(0, (r, e) -> r + e) +assert 9 == [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r, e) -> r + e) +assert 9 == [1, 2, 3].stream().map((e) -> e + 1).reduce(0, (r, e) -> {r + e}) +assert 32 == ((e) -> e + 1)(2) + ((e, f) -> e + f)(2, 3) + ((e, f, g) -> e * f * g)(2, 3, 4) + +assert 24 == ((e, f, g) -> {e * f * g})(2, 3, 4) +assert 24 == ((int e, int f, int g) -> { + int tmpE = e; + int tmpF = f; + int tmpG = g; + return tmpE * tmpF * tmpG; +})(2, 3, 4) +assert 24 == ((int e, int f, int g=4) -> { + int tmpE = e; + int tmpF = f; + int tmpG = g; + return tmpE * tmpF * tmpG; +})(2, 3) + +def list = [2, 3, 1] +Collections.sort(list, (n1, n2) -> n1 <=> n2) +assert [1, 2, 3] == list + +assert 1 == (e -> e)(1) +assert 2 == (() -> 2)() + +def lambda = e -> e; +assert 1 == lambda(1) + +lambda = e -> e + 1; +assert 2 == lambda(1) + +int sum = 0; +[1, 2, 3].forEach(e -> { + sum += e +}) +assert 6 == sum; + +def c = { (e) -> e * 2 } +assert 6 == c()(3) + +c = { (e) -> { e * 2 } } +assert 6 == c()(3) + + + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/List_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/List_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/List_01.groovy new file mode 100644 index 0000000..bf97184 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/List_01.groovy @@ -0,0 +1,15 @@ +[] +[ + +] +[1, 2, 3] +[1, 2, 3,] +[[1, 2, 3], 2, 3] +[ + [1, + 2, + 3], + 2, + 3] + +[1, *[2, 3, 4], 5, 6, *[7, 8], *[9]] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_01.groovy new file mode 100644 index 0000000..d1238c2 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_01.groovy @@ -0,0 +1,79 @@ +null +true +false + + +1 +12 +123 + +1.2 +1.2f +1.2F +1.2d +1.2D +1.2g +1.2G + +0x1234567890abcdef +0X1234567890ABCDEF +0x1234567890abcdefi +0x1234567890abcdefl +0x1234567890abcdefg +0x1234567890abcdefI +0x1234567890abcdefL +0x1234567890abcdefG +0xabcdef +0xABCDEF +0xABCDEF +0xabcdef +0xABCDEF + +01234567 +01234567 +01234567 +01234567i +01234567l +01234567g +01234567I +01234567L +01234567G + +1__2 +2_12_3 +2__12__3 +2__12__3.1__2 +2__12__3.1__2 +12e10 +12e-10 +12e10 +12e-10 +12.12e10 +12.12e-10 +12.12e10 +12.12e-10 +12.12e-10f +12.12e-10d +12.12e-10g +12e-10F +120e-10D +11F +12D +1.1F +1.2D +12e-10G +12.1__2e-10f +12.1_2e-10d +1__12_2.12e-10g +0xab__cdef +0xAB__CD_EF +012__34567L + +0b010101 +0B10101011 +0B10101011i +0B10101011I +0B10101011l +0B10101011L +0B10101011g +0B10101011G \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_02.groovy new file mode 100644 index 0000000..88a9a5f --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_02.groovy @@ -0,0 +1,48 @@ +'123' +'abc' +'a1b2c3' +'a\tb\tc' +'a\nb\r\nc' +'$a$b$c' +'$1$2$3' +'$1$2\$3' +'\$1\$2\$3\ + hello world\ +' +"\$1\$2\$3\ + hello world\ +" +' nested "double quotes" ' +" nested 'quotes' " +' \6 1 digit is escaped' +' \665 2 digits are escaped, \'5\' is a character.' +' \3666 3 digits are escaped' +' \166 ' +" \166 " +' \u1234 ' + +'''abc''' +'''123''' +''' + ''hello world'' + 'hello' + ''world' + 'hi'' + \ + \t\r\n + $\$ + \u1234 + \123 +''' + +""" + ''hello world'' + 'hello' + ''world' + 'hi'' + \ + \t\r\n + \$ + \u1234 + \123 +""" http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_03.groovy new file mode 100644 index 0000000..ad2b25e --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Literal_03.groovy @@ -0,0 +1,3 @@ +/\123 \/ abc \u1234 \r\n\$/ + +$/\123 \/ abc \u1234 \r\n/$ http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/LocalVariableDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/LocalVariableDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/LocalVariableDeclaration_01.groovy new file mode 100644 index 0000000..52e817a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/LocalVariableDeclaration_01.groovy @@ -0,0 +1,110 @@ +import groovy.transform.Field + +int a; +int b = 1; +int c = + 1; +final d = 1; +@Test2 e = 1; +@Test2 final f = 1; +final +@Test2 g = 1; + +int h, i = 1; +int j, + k = + 1; +int l = + 2, + m = + 1; +int n = + 1 +int o = + 2, + p = + 1 + +List list = [1, 2 + 6, [1, 2 + 3]] +List list2 = + [ + 1, + 2 + + 6, + [1, + 2 + + 3] + ] + +def (int x, int y) = [1, 2] + +@Test2 +def + (int q, + int r) = + [1, 2] + +def (int s, int t) = otherTuple + +def (int w, z) = [1, 2] +def (a2, int b2) = [1, 2] + +def (u, v) = [1, 2] + +def (int c2, String d2, java.lang.Double e2) = [1, '2', 3.3D] + +def cc = { + String bb = 'Test' + return bb; +} + +int xx = b c d e + +@Field static List list = [1, 2, 3] + +if (false) + def a = 5 + +if(false) + def a, b = 10 + +if(false) + def a = 9, b = 10 + +if (false) + def a = 5 +else + def b = 2 + +if(false) + def a, b = 10 +else + def a, b = 8 + +if(false) + def a = 9, b = 10 +else + def a = 6, b = 8 + +while(false) + def a = 5 + +while(false) + def a, b = 10 + +while(false) + def a = 9, b = 10 + +for(;;) + def a = 5 + +for(;;) + def a, b = 10 + +for(;;) + def a = 9, b = 10 + + + +Class<String>[] c +Class<?>[] c2 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Map_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Map_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Map_01.groovy new file mode 100644 index 0000000..7ed1a05 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Map_01.groovy @@ -0,0 +1,29 @@ +[a: 1, b: 2, c: 3] +[(a): 1, (b**2): x, c: 2 + 3] +['a': '1', 'b': 2, 'c': '3'] +[1: 2, 2: 3, 3: 4] +[1.1: 2, 2.2: 3, 3.3: 4] +[ + (a) + : + 1 + , + ( + b**2 + ) + : + x + , + c + : + 2 + + 3 +] + +[(a): '1', *: [(a + 1): 1, (b): 2], *: ['a': 1 + 2]] + +[:] +[ + : +] + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_01.groovy new file mode 100644 index 0000000..f27965a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_01.groovy @@ -0,0 +1,32 @@ +int plus(int a, int b) { + return a + b; +} + +int plus2(int a, + int b) +{ + return a + b; +} + +int plus3(int a, + int b) +throws + Exception1, + Exception2 +{ + return a + b; +} + +def <T> T someMethod() {} +def <T extends List> T someMethod2() {} +def <T extends A & B> T someMethod3() {} + +static m(a) {} +static m2(a, b) {} +static m3(a, b, c) {} +static Object m4(a, b, c) {} + +private String relativePath() { '' } +def foo() {} + + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_02.groovy new file mode 100644 index 0000000..97b731b --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodDeclaration_02.groovy @@ -0,0 +1,41 @@ +final int plus(int a, int b) { + return a + b; +} + +final plus(int a, int b) { + return a + b; +} + +@Test2 plus(int a, int b) { + return a + b; +} + +@Test2 +int plus(int a, int b) { + return a + b; +} + +@Test2 +final int plus(int a, int b) { + return a + b; +} + +@Test2 +@Test3 +synchronized final int plus(int a, int b) { + return a + b; +} + + +public void someMethod (java.lang.Class<String> clazz) {} +public void someMethod2 (java.lang.Class clazz) {} +public boolean someMethod3 (java.util.List<String> list) { + list instanceof java.util.List +} + +/* return element i,j of infinite matrix A */ +def A(i, j) { + return 1.0D / ((i+j) * (i + j + 1.0D) / 2.0D + i + 1.0D) +} + +String m(Integer a, ... params) {} http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodPointer_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodPointer_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodPointer_01x.groovy new file mode 100644 index 0000000..3438cde --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodPointer_01x.groovy @@ -0,0 +1,5 @@ +def shell = new GroovyShell() +assert shell.evaluate("x = String.&toUpperCase; x('abc')") == "ABC" +assert shell.evaluate("x = 'abc'.&toUpperCase; x()") == "ABC" +assert shell.evaluate("x = Integer.&parseInt; x('123')") == 123 +assert shell.evaluate("x = 3.&parseInt; x('123')") == 123 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodReference_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodReference_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodReference_01x.groovy new file mode 100644 index 0000000..2c5f1ce --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/MethodReference_01x.groovy @@ -0,0 +1,85 @@ +import java.util.stream.Collectors + +// class::staticMethod +assert ['1', '2', '3'] == [1, 2, 3].stream().map(Integer::toString).collect(Collectors.toList()) + +// class::instanceMethod +assert ['A', 'B', 'C'] == ['a', 'b', 'c'].stream().map(String::toUpperCase).collect(Collectors.toList()) + + + +def robot = new Robot(); + +// instance::instanceMethod +assert ['Hi, Jochen', 'Hi, Paul', 'Hi, Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::greet).collect(Collectors.toList()) + +// class::staticMethod +assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getText).collect(Collectors.toList()) +assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(BasePerson::getText).collect(Collectors.toList()) + +// instance::staticMethod +assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::firstCharOfName).collect(Collectors.toList()) + +// class::instanceMethod +assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(Collectors.toList()) + + +// ---------------------------------- +class BasePerson { + public static String getText(Person p) { + return p.name; + } +} + +class Person extends BasePerson { + private String name; + + public Person(String name) { + this.name = name + } + + public String getName() { + return this.name; + } + +} +class Robot { + public String greet(Person p) { + return "Hi, ${p.name}" + } + + public static char firstCharOfName(Person p) { + return p.getName().charAt(0); + } +} + +def mr = String::toUpperCase +assert 'ABC' == mr('abc') +assert 'ABC' == String::toUpperCase('abc') + +assert new HashSet() == HashSet::new() +assert new String() == String::new() +assert 1 == Integer::new(1) +assert new String[0] == String[]::new(0) +assert new String[0] == String[]::new('0') +assert new String[1][2] == String[][]::new(1, 2) +assert new String[1][2][3] == String[][][]::new(1, 2, 3) + +assert [new String[1], new String[2], new String[3]] == [1, 2, 3].stream().map(String[]::new).collect(Collectors.toList()) +assert [1, 2, 3] as String[] == [1, 2, 3].stream().map(String::valueOf).toArray(String[]::new) + + +def a = String[][]::new(1, 2) +def b = new String[1][2] +assert a.class == b.class && a == b + +a = String[][][]::new(1, 2) +b = new String[1][2][] +assert a.class == b.class && a == b + +a = String[][][][]::new(1, 2) +b = new String[1][2][][] +assert a.class == b.class && a == b + + + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_01.groovy new file mode 100644 index 0000000..c0c3a65 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_01.groovy @@ -0,0 +1 @@ +package com.groovyhelp.core \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_02.groovy new file mode 100644 index 0000000..f8181bc --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_02.groovy @@ -0,0 +1 @@ +package com.groovyhelp.core http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_03.groovy new file mode 100644 index 0000000..c4d5a5a --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_03.groovy @@ -0,0 +1 @@ +package com.groovyhelp.core; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_04.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_04.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_04.groovy new file mode 100644 index 0000000..8f0fe40 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_04.groovy @@ -0,0 +1,20 @@ +#!/usr/bin/env groovy +/* + * 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. + */ +package com.groovyhelp.core; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_05.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_05.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_05.groovy new file mode 100644 index 0000000..c0c5d62 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_05.groovy @@ -0,0 +1,23 @@ +#!/usr/bin/env groovy +/* + * 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. + */ +package com.groovyhelp.core; +/** + * Created by Daniel.Sun on 2016/08/17. + */ \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_06.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_06.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_06.groovy new file mode 100644 index 0000000..c555fd0 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/PackageDeclaration_06.groovy @@ -0,0 +1 @@ +package def.in.as.trait; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Return_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Return_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Return_01.groovy new file mode 100644 index 0000000..17ad319 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Return_01.groovy @@ -0,0 +1,8 @@ +return +return; +return 1; +return 2 +return +3; +return +4 \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/SafeIndex_01x.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/SafeIndex_01x.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/SafeIndex_01x.groovy new file mode 100644 index 0000000..2d1c584 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/SafeIndex_01x.groovy @@ -0,0 +1,10 @@ +assert null == null?[1]; +assert null == null?[1]?[1, 2]; +assert null == null?[1]?[1, 2]?[1, 2, 3]; + +def a = null; +assert null == a?[1, 2]; + +def f() {return null} +assert null == f()?[1]; + http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Switch_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Switch_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Switch_01.groovy new file mode 100644 index 0000000..6719de8 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Switch_01.groovy @@ -0,0 +1,60 @@ +switch (a) { + case 1: + break; + case 2: + break; +} + +switch (a) { + case 1: + break; + case 2: + break; + default: + break; +} + +switch (a) { + case 1: + case 2: + break; + case 3: + break; + default: + break; +} + +switch (a) { + case 1: + case 2 + 3: + break; + case 3: + break; + case 4 + 2: + case 5: + default: + break; +} + +switch (a) { + case 1: + case 2 + 3: break; + case 3: break; + case 4 + 2: + case 5: + default: break; +} + +switch (a) {case 1: + case 2 + 3: break; + case 3: break; + case 4 + 2: + case 5: + default: break;} + +switch (a) { + case 1: + int x = 1; + default: + int y = 2; +} http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Synchronized_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Synchronized_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Synchronized_01.groovy new file mode 100644 index 0000000..a3cbffe --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Synchronized_01.groovy @@ -0,0 +1,36 @@ +synchronized ('a') +{ + assert true +} + +synchronized ('a') { + assert true +} + +synchronized ('a') {assert true +} + +synchronized ('a') {assert true} + +synchronized ('a') {assert true;} + +synchronized ('a') { + assert true + assert true +} + +synchronized ('a') { + assert true; + assert true +} + +synchronized ('a') { + assert true; assert true +} + +synchronized ('a') {assert true; assert true +} + +synchronized ('a') {assert true; assert true} + +synchronized ('a') {assert true; assert true;} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/Throw_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/Throw_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Throw_01.groovy new file mode 100644 index 0000000..3e67db8 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/Throw_01.groovy @@ -0,0 +1,2 @@ +throw e; +throw e \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_01.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_01.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_01.groovy new file mode 100644 index 0000000..2495e32 --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_01.groovy @@ -0,0 +1,42 @@ +package core + +trait A {} +trait B<T> {} +trait C<T extends A> {} +trait D<T extends A & B> {} +trait E<T extends A & B & C> {} +trait F<T extends A & B & C> extends A {} +trait F2 extends A<T> {} +trait G1<T extends A & B & C> extends A implements X {} +trait G2<T extends A & B & C> extends A<T> implements X<T> {} +trait G3 extends A<T> implements X<T> {} +trait G4 extends A implements X<T> {} +trait G5 extends A implements X {} +trait G2<T extends A & B & C> extends A<T> implements X<T> {} +trait H<T extends A & B & C> extends A implements X, Y {} +trait I<T extends A & B & C> extends A implements X, Y, Z {} +public trait J<T extends A & B & C> extends A implements X, Y, Z {} +@Test2 public trait K<T extends A & B & C> extends A implements X, Y, Z {} +@Test2 @Test3 public trait L<T extends A & B & C> extends A implements X, Y, Z {} + +@Test2 +@Test3 +public +trait M +< + T extends + A & + B & + C +> +extends +A +implements +X, +Y, +Z + { + + } + +trait t {} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_02.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_02.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_02.groovy new file mode 100644 index 0000000..c4b2dba --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_02.groovy @@ -0,0 +1,40 @@ +trait AA { + { + println 123 + } +} + +trait BB { + static { + println '123' + } +} + +trait CC { + static + { + println '123' + } +} + +trait DD { + static { + println '123' + } + + { + println 'abc' + } + + static { + println '234' + } + + { + println 'bcd' + } +} + +trait EE {{}} +trait FF {static {}} +trait GG {static {};{}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/groovy/blob/91c04014/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_03.groovy ---------------------------------------------------------------------- diff --git a/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_03.groovy b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_03.groovy new file mode 100644 index 0000000..c4bde4e --- /dev/null +++ b/subprojects/groovy-antlr4-grammar/src/test/resources/core/TraitDeclaration_03.groovy @@ -0,0 +1,48 @@ +import java.sql.SQLException + +trait AAA { + public AAA() { + + } + + public AAA(String name) { + + } + + @Test2 + public AAA(String name, int age) throws Exception { + + } + + AAA(String name, int age, String title) throws Exception { + + } + + private AAA(String name, int age, String title, double income) throws Exception { + + } + + @Test2 + public String sayHello(String name) { + return "Hello, $name"; + } + + @Test2 + public <T> T sayHello2(T name) throws IOException, SQLException { + return "Hello, $name"; + } + + public static privateStaticMethod(){} + + public void m(final int param) {} + public void m2(def param) {} + public void m3(final int param1, long param2, final String param3) {} + + def "hello world"(p1, p2) { + println "$p1, $p2" + } + + def run() { + this."hello world"('ab', 'bc') + } +}