* FYI: New StrictMath.tanh test
@ 2006-08-02 18:19 Carsten Neumann
0 siblings, 0 replies; only message in thread
From: Carsten Neumann @ 2006-08-02 18:19 UTC (permalink / raw)
To: mauve-patches
[-- Attachment #1: Type: text/plain, Size: 464 bytes --]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Added a test for the tanh function.
Cheers,
Carsten
2006-08-02 Carsten Neumann <cn-develop@gmx.net>
* gnu/testlet/java/lang/StrictMath/tanh.java: New test.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFE0Oy5d4NEZjs4PvgRAs5BAKCT3deR0A77o1GAp+9xPbVVYVkRyQCeNnI3
uxh6l5WkjoLDpPEpivlEZiM=
=4qei
-----END PGP SIGNATURE-----
[-- Attachment #2: java.lang.StrictMath.tanh.diff --]
[-- Type: text/x-patch, Size: 3392 bytes --]
Index: gnu/testlet/java/lang/StrictMath/tanh.java
===================================================================
RCS file: gnu/testlet/java/lang/StrictMath/tanh.java
diff -N gnu/testlet/java/lang/StrictMath/tanh.java
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/lang/StrictMath/tanh.java 2 Aug 2006 18:04:41 -0000
@@ -0,0 +1,116 @@
+// Tags: JDK1.5
+
+// Copyright (C) 2006 Carsten Neumann <cn-develop@gmx.net>
+
+// This file is part of Mauve.
+
+// Mauve is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// Mauve is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Mauve; see the file COPYING. If not, write to
+// the Free Software Foundation, 59 Temple Place - Suite 330,
+// Boston, MA 02111-1307, USA.
+
+package gnu.testlet.java.lang.StrictMath;
+
+import gnu.testlet.Testlet;
+import gnu.testlet.TestHarness;
+
+public class tanh implements Testlet
+{
+ /**
+ * These values are used as arguments to cbrt.
+ * The values are somewhat arbitrary, but ensure that all code paths
+ * are tested.
+ */
+ private static double[] inputValues =
+ {
+ 0.0,
+ Double.NaN,
+ Double.POSITIVE_INFINITY,
+ Double.NEGATIVE_INFINITY,
+ 2.7755575615628e-16, // ~ 2^-55
+ -2.7755575615628e-16, // ~ -2^-55
+ 2.5123456789e-16, // < 2^-55
+ -2.5123456789e-16, // > -2^-55
+ 0.123456789,
+ -0.123456789,
+ 0.987654321,
+ -0.987654321,
+ 1.0000000000000000123,
+ -1.0000000000000000123,
+ 1.123456789,
+ -1.123456789,
+ 21.999999999999999876,
+ -21.999999999999999876,
+ 22.000000000000000123,
+ -22.000000000000000123,
+ 25.987654321,
+ -25.987654321,
+ };
+
+ /**
+ * These values are the expected results, obtained from the RI.
+ */
+ private static double[] outputValues =
+ {
+ 0.0,
+ Double.NaN,
+ 1.0,
+ -1.0,
+ 2.7755575615627996E-16,
+ -2.7755575615627996E-16,
+ 2.5123456789E-16,
+ -2.5123456789E-16,
+ 0.12283336405919822,
+ -0.12283336405919822,
+ 0.7563603430619676,
+ -0.7563603430619676,
+ 0.7615941559557649,
+ -0.7615941559557649,
+ 0.8087679479619252,
+ -0.8087679479619252,
+ 1.0,
+ -1.0,
+ 1.0,
+ -1.0,
+ 1.0,
+ -1.0,
+ };
+
+ public void test(TestHarness harness)
+ {
+ double res;
+
+ for (int i = 0; i < inputValues.length; ++i)
+ {
+ res = StrictMath.tanh(inputValues[i]);
+
+ // exact equality seems appropriate for StrictMath
+ harness.check(res, outputValues[i]);
+ }
+ }
+
+ /**
+ * Run this on the RI to obtain the expected output values.
+ */
+ public static void main(String[] argv)
+ {
+ double res;
+
+ for (int i = 0; i < inputValues.length; ++i)
+ {
+ res = StrictMath.tanh(inputValues[i]);
+
+ System.out.println(Double.toString(res));
+ }
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2006-08-02 18:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-02 18:19 FYI: New StrictMath.tanh test 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).