FYI: Fix BigDecimalInteger test and make exceptions cause failure

View: New views
1 Messages — Rating Filter:   Alert me  

FYI: Fix BigDecimalInteger test and make exceptions cause failure

by gnu_andrew :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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

        * 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

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)