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 2021/03/01 01:05:27 UTC

[groovy] 04/04: GROOVY-9797: Implemented tests for double. (closes #1504)

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 5934481ae0e7427d83e0c698ffec846f131bdb06
Author: Otto Vayrynen <ot...@tuni.fi>
AuthorDate: Sat Feb 27 16:45:02 2021 +0200

    GROOVY-9797: Implemented tests for double. (closes #1504)
---
 src/test/groovy/bugs/Groovy9797.groovy | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/test/groovy/bugs/Groovy9797.groovy b/src/test/groovy/bugs/Groovy9797.groovy
index 0e588ff..1e71873 100644
--- a/src/test/groovy/bugs/Groovy9797.groovy
+++ b/src/test/groovy/bugs/Groovy9797.groovy
@@ -46,4 +46,19 @@ class Groovy9797 extends GroovyTestCase {
         int positiveZeroBits = Float.floatToIntBits(0.0f)
         assertNotSame(negativeZeroBits, positiveZeroBits)
     }
+
+    // Test with string conversion
+    void testDoubleToString() {
+        double negativeZero = -0.0d
+        double positiveZero = 0.0d
+        assertToString(negativeZero, '-0.0')
+        assertToString(positiveZero, '0.0')
+    }
+
+    // Test with long bits
+    void testNegativePositiveZeroDoubleLongBitsNotSame() {
+        long negativeZeroBits = Double.doubleToLongBits(-0.0d)
+        long positiveZeroBits = Double.doubleToLongBits(0.0d)
+        assertNotSame(negativeZeroBits, positiveZeroBits)
+    }
 }