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 2022/09/17 14:07:16 UTC

[groovy] branch GROOVY_3_0_X updated (51239f8fd8 -> 2004c79807)

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

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


    from 51239f8fd8 GROOVY-10757: create expression for implicit-`this` method call receiver
     new 180314aa0d assert fails because by default `@ToString` `includePackage` property is set to `true` returning package name along with object name i.e. `groovy.Element(Helium, 2)` is returned value on the right hand side
     new eb08e93d69 Use static `valueOf(String)` method instead of the deprecated `new Integer(String)` constructor
     new 49351926c0 Avoid inconvertible types warning at the `assert composite*.id == [1,2]` as left hand side is `ArrayList<Long>` while right hand side is `ArrayList<Integer>`
     new 1a784c77e0 Equivalency to Java `equals(Object)` and `==` respectively
     new 2e8adcb763 Add membership negation assert example
     new 2004c79807 Trivial tweak for Operators documentation

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


Summary of changes:
 src/spec/doc/core-operators.adoc   | 9 +++++----
 src/spec/test/OperatorsTest.groovy | 6 ++++--
 2 files changed, 9 insertions(+), 6 deletions(-)


[groovy] 03/06: Avoid inconvertible types warning at the `assert composite*.id == [1,2]` as left hand side is `ArrayList` while right hand side is `ArrayList`

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

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

commit 49351926c0307800c99f855899941c3222846974
Author: Alex Golub <a1...@gmail.com>
AuthorDate: Fri Sep 16 19:29:09 2022 +0300

    Avoid inconvertible types warning at the `assert composite*.id == [1,2]` as left hand side is `ArrayList<Long>` while right hand side is `ArrayList<Integer>`
    
    (cherry picked from commit 5dec8691ff0c4da4c2cb8c135cf93775092b9ffc)
---
 src/spec/test/OperatorsTest.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spec/test/OperatorsTest.groovy b/src/spec/test/OperatorsTest.groovy
index 122bc61894..636d7fe554 100644
--- a/src/spec/test/OperatorsTest.groovy
+++ b/src/spec/test/OperatorsTest.groovy
@@ -421,7 +421,7 @@ assert null*.make == null                             // <3>
         assertScript '''
 // tag::spreaddot_iterable[]
 class Component {
-    Long id
+    Integer id
     String name
 }
 class CompositeObject implements Iterable<Component> {


[groovy] 02/06: Use static `valueOf(String)` method instead of the deprecated `new Integer(String)` constructor

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

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

commit eb08e93d697b0b30ba845ec82b5b99b14c872370
Author: Alex Golub <a1...@gmail.com>
AuthorDate: Fri Sep 16 19:05:46 2022 +0300

    Use static `valueOf(String)` method instead of the deprecated `new Integer(String)` constructor
    
    (cherry picked from commit 6f03d16320ee2b48954e37b93bad8653eb4de540)
---
 src/spec/test/OperatorsTest.groovy | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/spec/test/OperatorsTest.groovy b/src/spec/test/OperatorsTest.groovy
index 0393a4770a..122bc61894 100644
--- a/src/spec/test/OperatorsTest.groovy
+++ b/src/spec/test/OperatorsTest.groovy
@@ -332,7 +332,7 @@ assert user.@name == 'Bob'                   // <1>
             // tag::constructor_refs[]
             @CompileStatic
             void constructorRefs() {
-                assert [1, 2, 3] == ['1', '2', '3'].stream().map(Integer::new).collect(toList())  // <1>
+                assert [1, 2, 3] == ['1', '2', '3'].stream().map(Integer::valueOf).collect(toList())  // <1>
 
                 def result = [1, 2, 3].stream().toArray(Integer[]::new)                           // <2>
                 assert result instanceof Integer[]


[groovy] 04/06: Equivalency to Java `equals(Object)` and `==` respectively

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

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

commit 1a784c77e0c3092ee60ff45242fcd3ed42171e0e
Author: Alex Golub <a1...@gmail.com>
AuthorDate: Sat Sep 17 14:21:40 2022 +0300

    Equivalency to Java `equals(Object)` and `==` respectively
    
    (cherry picked from commit 18e5d2f7aed52d193999586e0576e660e1fb2a83)
---
 src/spec/doc/core-operators.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/spec/doc/core-operators.adoc b/src/spec/doc/core-operators.adoc
index 728a82b2b8..50d151e56e 100644
--- a/src/spec/doc/core-operators.adoc
+++ b/src/spec/doc/core-operators.adoc
@@ -802,8 +802,8 @@ include::{projectdir}/src/spec/test/OperatorsTest.groovy[tags=identity_op,indent
 ----
 <1> Create a list of strings
 <2> Create another list of strings containing the same elements
-<3> using `==`, we test object equality
-<4> but using `is`, we can check that references are distinct
+<3> using `==`, we test object equality, equivalent to `list1.equals(list2)` in Java
+<4> but using `is`, we can check that references are distinct,  equivalent to `list1 != list2` in Java
 
 === Coercion operator
 


[groovy] 01/06: assert fails because by default `@ToString` `includePackage` property is set to `true` returning package name along with object name i.e. `groovy.Element(Helium, 2)` is returned value on the right hand side

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

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

commit 180314aa0d722b3527cf5d732c3b1c0d36e6ada2
Author: Alex Golub <a1...@gmail.com>
AuthorDate: Fri Sep 16 14:08:04 2022 +0300

    assert fails because by default `@ToString` `includePackage` property is set to `true` returning package name along with object name i.e. `groovy.Element(Helium, 2)` is returned value on the right hand side
    
    (cherry picked from commit 1fdcedb590a743a5b2cc1fec525031a2a92360cc)
---
 src/spec/doc/core-operators.adoc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/spec/doc/core-operators.adoc b/src/spec/doc/core-operators.adoc
index 24699c50d7..728a82b2b8 100644
--- a/src/spec/doc/core-operators.adoc
+++ b/src/spec/doc/core-operators.adoc
@@ -351,7 +351,7 @@ Groovy 3.0.0 introduces the Elvis operator, for example:
 --------------------------------------
 import groovy.transform.ToString
 
-@ToString
+@ToString(includePackage = false)
 class Element {
     String name
     int atomicNumber
@@ -996,4 +996,3 @@ Here is a complete list of the operators and their corresponding methods:
 | `~a`
 | a.bitwiseNegate()
 |====
-


[groovy] 05/06: Add membership negation assert example

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

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

commit 2e8adcb76371552c2d79af8192de451cf83a829c
Author: Alex Golub <a1...@gmail.com>
AuthorDate: Sat Sep 17 14:47:14 2022 +0300

    Add membership negation assert example
    
    (cherry picked from commit 9f72c55f89e2b278f99a91de5f7938958ad10124)
---
 src/spec/doc/core-operators.adoc   | 1 +
 src/spec/test/OperatorsTest.groovy | 1 +
 2 files changed, 2 insertions(+)

diff --git a/src/spec/doc/core-operators.adoc b/src/spec/doc/core-operators.adoc
index 50d151e56e..1298f7ef24 100644
--- a/src/spec/doc/core-operators.adoc
+++ b/src/spec/doc/core-operators.adoc
@@ -790,6 +790,7 @@ to calling `contains`, like in the following example:
 include::{projectdir}/src/spec/test/OperatorsTest.groovy[tags=membership_op,indent=0]
 ----
 <1> equivalent to calling `list.contains('Emmy')` or `list.isCase('Emmy')`
+<2> membership negation equivalent to calling `!list.contains('Emmy')` or `!list.isCase('Emmy')`
 
 === Identity operator
 
diff --git a/src/spec/test/OperatorsTest.groovy b/src/spec/test/OperatorsTest.groovy
index 636d7fe554..16911bbead 100644
--- a/src/spec/test/OperatorsTest.groovy
+++ b/src/spec/test/OperatorsTest.groovy
@@ -610,6 +610,7 @@ assert function(*args,5,6) == 26
         // tag::membership_op[]
         def list = ['Grace','Rob','Emmy']
         assert ('Emmy' in list)                     // <1>
+        assert ('Alex' !in list)                    // <2>
         // end::membership_op[]
     }
 


[groovy] 06/06: Trivial tweak for Operators documentation

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

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

commit 2004c798079a4cda4634fbf5965192cc58a26e42
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sat Sep 17 21:55:36 2022 +0800

    Trivial tweak for Operators documentation
    
    (cherry picked from commit 0b8f0dfd4a4d93f437a64502c7f8c44e04d5a711)
---
 src/spec/doc/core-operators.adoc   | 3 ++-
 src/spec/test/OperatorsTest.groovy | 1 +
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/spec/doc/core-operators.adoc b/src/spec/doc/core-operators.adoc
index 1298f7ef24..81b71e166f 100644
--- a/src/spec/doc/core-operators.adoc
+++ b/src/spec/doc/core-operators.adoc
@@ -804,7 +804,8 @@ include::{projectdir}/src/spec/test/OperatorsTest.groovy[tags=identity_op,indent
 <1> Create a list of strings
 <2> Create another list of strings containing the same elements
 <3> using `==`, we test object equality, equivalent to `list1.equals(list2)` in Java
-<4> but using `is`, we can check that references are distinct,  equivalent to `list1 != list2` in Java
+<4> using `is`, we can check that references are distinct,  equivalent to `list1 == list2` in Java
+<5> using `===` or `!==` (supported and recommended since Groovy 3.0.0), we can also check whether references are distinct or not, equivalent to `list1 == list2` and `list1 != list2` in Java
 
 === Coercion operator
 
diff --git a/src/spec/test/OperatorsTest.groovy b/src/spec/test/OperatorsTest.groovy
index 16911bbead..7b0c9b02ec 100644
--- a/src/spec/test/OperatorsTest.groovy
+++ b/src/spec/test/OperatorsTest.groovy
@@ -620,6 +620,7 @@ assert function(*args,5,6) == 26
         def list2 = ['Groovy 1.8','Groovy 2.0','Groovy 2.3']        // <2>
         assert list1 == list2                                       // <3>
         assert !list1.is(list2)                                     // <4>
+        assert list1 !== list2                                      // <5>
         // end::identity_op[]
     }