groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [groovy] 03/03: fix unintended illegal access
Date Thu, 18 Apr 2019 14:48:13 GMT
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 b053eff860193e8f72a498da1d02c4d49db85ab0
Author: Paul King <paulk@asert.com.au>
AuthorDate: Fri Apr 19 00:27:55 2019 +1000

    fix unintended illegal access
---
 .../test/resources/core/MethodReference_01x.groovy | 52 +++++++++++-----------
 1 file changed, 25 insertions(+), 27 deletions(-)

diff --git a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
index 997a7bf..dd3d116 100644
--- a/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
+++ b/subprojects/parser-antlr4/src/test/resources/core/MethodReference_01x.groovy
@@ -16,60 +16,62 @@
  *  specific language governing permissions and limitations
  *  under the License.
  */
-import java.util.stream.Collectors
+import java.util.stream.Stream
+
+import static java.util.stream.Collectors.toList
+import static java.util.stream.Collectors.toMap
 
 // class::staticMethod
-assert ['1', '2', '3'] == [1, 2, 3].stream().map(Integer::toString).collect(Collectors.toList())
+assert ['1', '2', '3'] == [1, 2, 3].stream().map(Integer::toString).collect(toList())
 
 // class::instanceMethod
-assert ['A', 'B', 'C'] == ['a', 'b', 'c'].stream().map(String::toUpperCase).collect(Collectors.toList())
-
+assert ['A', 'B', 'C'] == ['a', 'b', 'c'].stream().map(String::toUpperCase).collect(toList())
 
-
-def robot = new Robot();
+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())
+assert ['Hi, Jochen', 'Hi, Paul', 'Hi, Daniel'] == [new Person('Jochen'), new Person('Paul'),
new Person('Daniel')].stream().map(robot::greet).collect(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())
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getText).collect(toList())
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(BasePerson::getText).collect(toList())
 
 // instance::staticMethod
-assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::firstCharOfName).collect(Collectors.toList())
+assert ['J', 'P', 'D'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(robot::firstCharOfName).collect(toList())
 
 // class::instanceMethod
-assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(Collectors.toList())
+assert ['Jochen', 'Paul', 'Daniel'] == [new Person('Jochen'), new Person('Paul'), new Person('Daniel')].stream().map(Person::getName).collect(toList())
 
 // class::instanceMethod
-assert 6 == java.util.stream.Stream.of(1, 2, 3).reduce(0, BigDecimal::add)
+assert 6G == Stream.of(1G, 2G, 3G).reduce(0G, BigInteger::add)
 
 // ----------------------------------
 class BasePerson {
-    public static String getText(Person p) {
-        return p.name;
+    static String getText(Person p) {
+        return p.name
     }
 }
 
 class Person extends BasePerson {
-    private String name;
+    private String name
 
-    public Person(String name) {
+    Person(String name) {
         this.name = name
     }
 
-    public String getName() {
-        return this.name;
+    String getName() {
+        return this.name
     }
 
 }
+
 class Robot {
-    public String greet(Person p) {
+    String greet(Person p) {
         return "Hi, ${p.name}"
     }
 
-    public static char firstCharOfName(Person p) {
-        return p.getName().charAt(0);
+    static char firstCharOfName(Person p) {
+        return p.getName().charAt(0)
     }
 }
 
@@ -77,7 +79,7 @@ def mr = String::toUpperCase
 assert 'ABC' == mr('abc')
 assert 'ABC' == String::toUpperCase('abc')
 
-def m = ['apple', 'banana', 'orange'].stream().collect(Collectors.toMap(e -> e.charAt(0),
e -> e, (e1, e2) -> e1, LinkedHashMap<String, String>::new))
+def m = ['apple', 'banana', 'orange'].stream().collect(toMap(e -> e.charAt(0), e ->
e, (e1, e2) -> e1, LinkedHashMap<String, String>::new))
 assert m instanceof LinkedHashMap
 assert ['a', 'b', 'o'] as TreeSet == m.keySet() as TreeSet
 assert ['apple', 'banana', 'orange'] as TreeSet == m.values() as TreeSet
@@ -93,10 +95,9 @@ 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 [new String[1], new String[2], new String[3]] == [1, 2, 3].stream().map(String[]::new).collect(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
@@ -108,6 +109,3 @@ assert a.class == b.class && a == b
 a = String[][][][]::new(1, 2)
 b = new String[1][2][][]
 assert a.class == b.class && a == b
-
-
-


Mime
View raw message