You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/11/17 11:56:03 UTC

[4/7] groovy git commit: Add a test to verify that changes to generating hashCode() for instances with null fields and properties and EqualsAndHashCodeASTTransformation have no impact on the value returned

Add a test to verify that changes to generating hashCode() for instances with null fields and properties and EqualsAndHashCodeASTTransformation have no impact on the value returned


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1513fa85
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1513fa85
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1513fa85

Branch: refs/heads/GROOVY_2_6_X
Commit: 1513fa85b5bfcc61a55478d7aaa199ac6bb09cf4
Parents: dc1e5ac
Author: Marcin Erdmann <er...@gmail.com>
Authored: Sun Nov 12 10:26:39 2017 +0000
Committer: paulk <pa...@asert.com.au>
Committed: Fri Nov 17 21:55:36 2017 +1000

----------------------------------------------------------------------
 .../transform/CanonicalComponentsTransformTest.groovy   | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1513fa85/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy b/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
index 6450f8e..6457315 100644
--- a/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
+++ b/src/test/org/codehaus/groovy/transform/CanonicalComponentsTransformTest.groovy
@@ -761,6 +761,18 @@ class CanonicalComponentsTransformTest extends GroovyShellTestCase {
             assert d1 == d2
         """
     }
+
+    void testHashCodeForInstanceWithNullPropertyAndField() {
+        new GroovyShell().evaluate """
+            import groovy.transform.*
+            @EqualsAndHashCode(includeFields = true)
+            class FieldAndPropertyIncludedInHashCode {            
+                private String field
+                String property
+            }
+            assert new FieldAndPropertyIncludedInHashCode().hashCode() == 442087
+        """
+    }
 }
 
 @TupleConstructor