This is the mail archive of the
mauve-patches@sourceware.org
mailing list for the Mauve project.
FYI: StrictMath tests, test NaN return value
- From: Carsten Neumann <cn-develop at gmx dot net>
- To: mauve-patches at sources dot redhat dot com
- Date: Thu, 03 Aug 2006 20:32:15 +0200
- Subject: FYI: StrictMath tests, test NaN return value
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
this adds testing of the return value for NaN input to the StrictMath
methods cbrt, cosh, expm1, sinh and tanh. The RI returns the argument
(not necessarily the Double.NaN constant).
These tests currently fail, will work on this next.
Cheers,
Carsten
2006-08-03 Carsten Neumann <cn-develop@gmx.net>
* gnu/testlet/java/lang/StrictMath/cbrt.java
(NaNValues): New field.
(testInputValues): New method.
(testNaNValues): New method.
(test): call testInputValues and testNaNValues.
* gnu/testlet/java/lang/StrictMath/cosh.java
(NaNValues): New field.
(testInputValues): New method
(testNaNValues): New method.
(test): call testInputValues and testNaNValues.
* gnu/testlet/java/lang/StrictMath/expm1.java
(NaNValues): New field.
(testInputValues): New method.
(testNaNValues): New method.
(test): call testInputValues and testNaNValues.
* gnu/testlet/java/lang/StrictMath/sinh.java
(NaNValues): New field.
(testInputValues): New method.
(testNaNValues): New method.
(test): call testInputValues and testNaNValues.
* gnu/testlet/java/lang/StrictMath/tanh.java
(NaNValues): New field.
(testInputValues): New method.
(testNaNValues): New method.
(test): call testInputValues and testNaNValues.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFE0kEvd4NEZjs4PvgRAlYkAJ9Z/q+JPisyqiSesNI1Q9Nl5agHtQCgsj8P
kgN8pNJKcvLMQsE2MMTK+8A=
=eGCq
-----END PGP SIGNATURE-----
Index: gnu/testlet/java/lang/StrictMath/cbrt.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/StrictMath/cbrt.java,v
retrieving revision 1.2
diff -u -r1.2 cbrt.java
--- gnu/testlet/java/lang/StrictMath/cbrt.java 24 Jul 2006 17:16:37 -0000 1.2
+++ gnu/testlet/java/lang/StrictMath/cbrt.java 3 Aug 2006 18:23:35 -0000
@@ -72,7 +72,20 @@
1.3956124250860895
};
- public void test(TestHarness harness)
+ private static long[] NaNValues =
+ {
+ 0x7fff800000000000L,
+ 0xffff800000000000L,
+ 0x7fff812345abcdefL,
+ 0xffff812345abcdefL,
+
+ 0x7fff000000000001L,
+ 0xffff000000000001L,
+ 0x7fff7654321fedcbL,
+ 0xffff7654321fedcbL
+ };
+
+ private void testInputValues(TestHarness harness)
{
double res;
@@ -86,6 +99,30 @@
}
/**
+ * Test if input NaN is returned unchanged.
+ */
+ private void testNaN(TestHarness harness)
+ {
+ long bitsNaN;
+ double valNaN;
+
+ for (int i = 0; i < NaNValues.length; ++i)
+ {
+ bitsNaN = NaNValues[i];
+ valNaN = Double.longBitsToDouble(bitsNaN);
+
+ harness.check(Double.doubleToRawLongBits(StrictMath.cbrt(valNaN)),
+ bitsNaN);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testInputValues(harness);
+ testNaN(harness);
+ }
+
+ /**
* Run this on the RI to obtain the expected output values.
*/
public static void main(String[] argv)
Index: gnu/testlet/java/lang/StrictMath/cosh.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/StrictMath/cosh.java,v
retrieving revision 1.2
diff -u -r1.2 cosh.java
--- gnu/testlet/java/lang/StrictMath/cosh.java 2 Aug 2006 18:43:52 -0000 1.2
+++ gnu/testlet/java/lang/StrictMath/cosh.java 3 Aug 2006 18:23:35 -0000
@@ -90,7 +90,20 @@
Double.POSITIVE_INFINITY
};
- public void test(TestHarness harness)
+ private static long[] NaNValues =
+ {
+ 0x7fff800000000000L,
+ 0xffff800000000000L,
+ 0x7fff812345abcdefL,
+ 0xffff812345abcdefL,
+
+ 0x7fff000000000001L,
+ 0xffff000000000001L,
+ 0x7fff7654321fedcbL,
+ 0xffff7654321fedcbL
+ };
+
+ private void testInputValues(TestHarness harness)
{
double res;
@@ -104,6 +117,30 @@
}
/**
+ * Test if input NaN is returned unchanged.
+ */
+ private void testNaN(TestHarness harness)
+ {
+ long bitsNaN;
+ double valNaN;
+
+ for (int i = 0; i < NaNValues.length; ++i)
+ {
+ bitsNaN = NaNValues[i];
+ valNaN = Double.longBitsToDouble(bitsNaN);
+
+ harness.check(Double.doubleToRawLongBits(StrictMath.cosh(valNaN)),
+ bitsNaN);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testInputValues(harness);
+ testNaN(harness);
+ }
+
+ /**
* Run this on the RI to obtain the expected output values.
*/
public static void main(String[] argv)
Index: gnu/testlet/java/lang/StrictMath/expm1.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/StrictMath/expm1.java,v
retrieving revision 1.2
diff -u -r1.2 expm1.java
--- gnu/testlet/java/lang/StrictMath/expm1.java 2 Aug 2006 18:43:52 -0000 1.2
+++ gnu/testlet/java/lang/StrictMath/expm1.java 3 Aug 2006 18:23:36 -0000
@@ -90,7 +90,20 @@
-1.0
};
- public void test(TestHarness harness)
+ private static long[] NaNValues =
+ {
+ 0x7fff800000000000L,
+ 0xffff800000000000L,
+ 0x7fff812345abcdefL,
+ 0xffff812345abcdefL,
+
+ 0x7fff000000000001L,
+ 0xffff000000000001L,
+ 0x7fff7654321fedcbL,
+ 0xffff7654321fedcbL
+ };
+
+ private void testInputValues(TestHarness harness)
{
double res;
@@ -104,6 +117,30 @@
}
/**
+ * Test if input NaN is returned unchanged.
+ */
+ private void testNaN(TestHarness harness)
+ {
+ long bitsNaN;
+ double valNaN;
+
+ for (int i = 0; i < NaNValues.length; ++i)
+ {
+ bitsNaN = NaNValues[i];
+ valNaN = Double.longBitsToDouble(bitsNaN);
+
+ harness.check(Double.doubleToRawLongBits(StrictMath.expm1(valNaN)),
+ bitsNaN);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testInputValues(harness);
+ testNaN(harness);
+ }
+
+ /**
* Run this on the RI to obtain the expected output values.
*/
public static void main(String[] argv)
Index: gnu/testlet/java/lang/StrictMath/sinh.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/StrictMath/sinh.java,v
retrieving revision 1.2
diff -u -r1.2 sinh.java
--- gnu/testlet/java/lang/StrictMath/sinh.java 2 Aug 2006 18:43:52 -0000 1.2
+++ gnu/testlet/java/lang/StrictMath/sinh.java 3 Aug 2006 18:23:36 -0000
@@ -90,7 +90,20 @@
Double.NEGATIVE_INFINITY,
};
- public void test(TestHarness harness)
+ private static long[] NaNValues =
+ {
+ 0x7fff800000000000L,
+ 0xffff800000000000L,
+ 0x7fff812345abcdefL,
+ 0xffff812345abcdefL,
+
+ 0x7fff000000000001L,
+ 0xffff000000000001L,
+ 0x7fff7654321fedcbL,
+ 0xffff7654321fedcbL
+ };
+
+ private void testInputValues(TestHarness harness)
{
double res;
@@ -104,6 +117,30 @@
}
/**
+ * Test if input NaN is returned unchanged.
+ */
+ private void testNaN(TestHarness harness)
+ {
+ long bitsNaN;
+ double valNaN;
+
+ for (int i = 0; i < NaNValues.length; ++i)
+ {
+ bitsNaN = NaNValues[i];
+ valNaN = Double.longBitsToDouble(bitsNaN);
+
+ harness.check(Double.doubleToRawLongBits(StrictMath.sinh(valNaN)),
+ bitsNaN);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testInputValues(harness);
+ testNaN(harness);
+ }
+
+ /**
* Run this on the RI to obtain the expected output values.
*/
public static void main(String[] argv)
Index: gnu/testlet/java/lang/StrictMath/tanh.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/lang/StrictMath/tanh.java,v
retrieving revision 1.2
diff -u -r1.2 tanh.java
--- gnu/testlet/java/lang/StrictMath/tanh.java 2 Aug 2006 18:43:52 -0000 1.2
+++ gnu/testlet/java/lang/StrictMath/tanh.java 3 Aug 2006 18:23:36 -0000
@@ -86,7 +86,20 @@
-1.0,
};
- public void test(TestHarness harness)
+ private static long[] NaNValues =
+ {
+ 0x7fff800000000000L,
+ 0xffff800000000000L,
+ 0x7fff812345abcdefL,
+ 0xffff812345abcdefL,
+
+ 0x7fff000000000001L,
+ 0xffff000000000001L,
+ 0x7fff7654321fedcbL,
+ 0xffff7654321fedcbL
+ };
+
+ private void testInputValues(TestHarness harness)
{
double res;
@@ -100,6 +113,30 @@
}
/**
+ * Test if input NaN is returned unchanged.
+ */
+ private void testNaN(TestHarness harness)
+ {
+ long bitsNaN;
+ double valNaN;
+
+ for (int i = 0; i < NaNValues.length; ++i)
+ {
+ bitsNaN = NaNValues[i];
+ valNaN = Double.longBitsToDouble(bitsNaN);
+
+ harness.check(Double.doubleToRawLongBits(StrictMath.tanh(valNaN)),
+ bitsNaN);
+ }
+ }
+
+ public void test(TestHarness harness)
+ {
+ testInputValues(harness);
+ testNaN(harness);
+ }
+
+ /**
* Run this on the RI to obtain the expected output values.
*/
public static void main(String[] argv)