public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
* FYI: Fix BigDecimalInteger test and make exceptions cause failure
@ 2008-09-01 23:03 Andrew John Hughes
  0 siblings, 0 replies; only message in thread
From: Andrew John Hughes @ 2008-09-01 23:03 UTC (permalink / raw)
  To: mauve-patches

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

This patch amends another of the Scanner tests so it correctly
uses harness.check (so we actually pass some tests).  It also
makes exceptions cause failure as they were being swallowed
by the Base class.

2008-09-01  Andrew John Hughes  <gnu_andrew@member.fsf.org>

	* gnu/testlet/java/util/Scanner/Base.java:
	(test(TestHarness)): Fail if an exception is thrown.
	* gnu/testlet/java/util/Scanner/BigDecimalInteger.java:
	Use harness.check.

-- 
Andrew :)

Support Free Java!
Contribute to GNU Classpath and the OpenJDK
http://www.gnu.org/software/classpath
http://openjdk.java.net
PGP Key: 94EFD9D8 (http://subkeys.pgp.net)
Fingerprint = F8EF F1EA 401E 2E60 15FA  7927 142C 2591 94EF D9D8

[-- Attachment #2: scanner-02.diff --]
[-- Type: text/plain, Size: 3313 bytes --]

Index: gnu/testlet/java/util/Scanner/Base.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/Scanner/Base.java,v
retrieving revision 1.1
diff -u -u -r1.1 Base.java
--- gnu/testlet/java/util/Scanner/Base.java	1 Sep 2008 22:22:39 -0000	1.1
+++ gnu/testlet/java/util/Scanner/Base.java	1 Sep 2008 22:56:10 -0000
@@ -69,6 +69,7 @@
     catch (Throwable e)
     {
       e.printStackTrace ();
+      myHarness.fail(e.toString());
     }
   }
 
Index: gnu/testlet/java/util/Scanner/BigDecimalInteger.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/java/util/Scanner/BigDecimalInteger.java,v
retrieving revision 1.1
diff -u -u -r1.1 BigDecimalInteger.java
--- gnu/testlet/java/util/Scanner/BigDecimalInteger.java	1 Sep 2008 22:22:39 -0000	1.1
+++ gnu/testlet/java/util/Scanner/BigDecimalInteger.java	1 Sep 2008 22:56:11 -0000
@@ -69,72 +69,33 @@
       {
 	decimals[i] = new BigDecimal (rand.nextDouble () - 0.5);
 	integers[i] = BigInteger.valueOf (rand.nextInt ());
-//                      if (i % 100 == 0)
-//                              System.out.println(i);
       }
 
     sBuff.append (decimals[0] + " " + integers[0]);
     for (i = 1; i < decimals.length; i++)
       {
 	sBuff.append (" " + decimals[i] + " " + integers[i]);
-//                      if (i % 100 == 0)
-//                              System.out.println(i);
       }
 
     inStr = sBuff.toString ();
-//              Scanner s = new Scanner (inStr);
     Scanner s = new Scanner (inStr);
-    //s.setUseLocale (false);
-//              System.out.println(inStr);
-
-//              System.out.println("len : " + inStr.length());
 
     i = 0;
     while (s.hasNext () && runsLeft > 0)
       {
-	fund = false;
 	failed = false;
-	if (s.hasNextBigDecimal ())
-	  {
-	    tmpDec = s.nextBigDecimal ();
-	    if (!tmpDec.equals (decimals[i]))
-	      {
-		failed = true;
-		this.myHarness.fail ("#" + i +
-				     " : bad result by nextBigDeciaml() : (" +
-				     tmpDec + " != " + decimals[i] +
-				     ") possibly needed : \"" + s.next () +
-				     "\"");
-	      }
-	    fund = true;
-	  }
-	else
-	  {
-	    this.myHarness.fail ("no BigDecimal found...");
-	  }
-	if (s.hasNextBigInteger ())
-	  {
-	    tmpInt = s.nextBigInteger ();
-	    if (!tmpInt.equals (integers[i]))
-	      {
-		failed = true;
-		this.myHarness.fail ("#" + i +
-				     " : bad result by nextBigInteger() : " +
-				     tmpInt + " != " + integers[i]);
-	      }
-	    fund = true;
-	  }
-	else
-	  {
-	    this.myHarness.fail ("no BigInteger found...");
-	  }
-
-//                      if (i % 100 == 0)
-//                              System.out.println(i);
+	fund = s.hasNextBigDecimal();
+	myHarness.check(fund, "hasNextBigDecimal()");
+	tmpDec = s.nextBigDecimal ();
+	myHarness.check(tmpDec, decimals[i], tmpDec + " == " + decimals[i]);
+	fund = s.hasNextBigInteger();
+	myHarness.check(fund, "hasNextBigInteger()");
+	tmpInt = s.nextBigInteger ();
+	myHarness.check(tmpInt, integers[i], tmpInt + " == " + integers[i]);
 	if (!fund)
 	  {
 	    this.myHarness.fail ("\"" + s.next () +
-				 "\" is neighter BigDecimal nor BigInteger");
+				 "\" is neither BigDecimal nor BigInteger");
 	  }
 	i++;
 	if (failed)

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

only message in thread, other threads:[~2008-09-01 23:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-09-01 23:03 FYI: Fix BigDecimalInteger test and make exceptions cause failure Andrew John Hughes

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