public inbox for mauve-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew John Hughes <gnu_andrew@member.fsf.org>
To: mauve-patches@sources.redhat.com
Subject: FYI: Fix BigDecimalInteger test and make exceptions cause failure
Date: Mon, 01 Sep 2008 23:03:00 -0000	[thread overview]
Message-ID: <20080901230235.GA21257@rivendell.middle-earth.co.uk> (raw)

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

                 reply	other threads:[~2008-09-01 23:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080901230235.GA21257@rivendell.middle-earth.co.uk \
    --to=gnu_andrew@member.fsf.org \
    --cc=mauve-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).