public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: StrictMath tests, test NaN return value
@ 2006-08-03 18:32 Carsten Neumann
  0 siblings, 0 replies; only message in thread
From: Carsten Neumann @ 2006-08-03 18:32 UTC (permalink / raw)
  To: mauve-patches

[-- Attachment #1: Type: text/plain, Size: 1523 bytes --]

-----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-----

[-- Attachment #2: StrictMath.NaN-tests.diff --]
[-- Type: text/x-patch, Size: 7406 bytes --]

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)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-08-03 18:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-03 18:32 FYI: StrictMath tests, test NaN return value Carsten Neumann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).