public inbox for mauve-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Dr Andrew John Hughes <ahughes@redhat.com>
To: Pavel Tisnovsky <ptisnovs@redhat.com>
Cc: mauve-discuss@sourceware.org
Subject: Re: Fix for test gnu/testlet/java/lang/Integer/parseInt.java
Date: Thu, 18 Aug 2011 15:46:00 -0000	[thread overview]
Message-ID: <20110818154546.GF9583@rivendell.middle-earth.co.uk> (raw)
In-Reply-To: <4E4D08C8.8010307@redhat.com>

On 14:42 Thu 18 Aug     , Pavel Tisnovsky wrote:
> Dr Andrew John Hughes wrote:
> 
> > As the old behaviour is specific to versions of Sun/Oracle's JDK implementation,
> > it should check that this implementation is being used as well, rather than just
> > the version.
> 
> Hi Andrew,
> 
> I've tried to add check for JDK/JRE implementation as you suggested. Patch for
> parseInt Mauve test is stored in an attachment.
> 
> Cheers,
> Pavel

This looks better, but you're still changing the old behaviour.  Not all Classpath
VMs are produced by the FSF.  As it's a workaround for Sun:

String[] javaVersion = System.getProperty("java.version").split("\\.");
String vendorID = System.getProperty("java.vendor");
// test of OpenJDK
if ("Sun Microsystems Inc.".equals(vendorID))
{
   return Integer.parseInt(javaVersion[1]) >= 7;
}
return true;

> --- gnu/testlet/java/lang/Integer/parseInt.java	2008-05-12 23:35:49.000000000 +0200
> +++ gnu/testlet/java/lang/Integer/parseInt.java	2011-08-17 17:17:16.000000000 +0200
> @@ -27,6 +27,26 @@
>  
>  public class parseInt implements Testlet
>  {
> +  /**
> +    * Returns true if tested JRE conformns to JDK 1.7 specification.
> +    */
> +  private static boolean conformToJDK17()
> +  {
> +    String[] javaVersion = System.getProperty("java.version").split("\\.");
> +    String vendorID = System.getProperty("java.vendor");
> +    // GNU CLASSPATH conform to JDK1.7, at least in case of Integer.parseInt() method
> +    if ("Free Software Foundation, Inc.".equals(vendorID))
> +      {
> +        return true;
> +      }
> +    // test of OpenJDK
> +    if ("Sun Microsystems Inc.".equals(vendorID))
> +      {
> +        return Integer.parseInt(javaVersion[1]) >= 7;
> +      }
> +    return false; // questionable
> +  }
> +
>    public void test(TestHarness harness)
>    {
>      int i;
> @@ -106,15 +126,30 @@
>      }
>    
>      // In JDK1.7, '+' is considered a valid character.
> -    try
> -      {
> -        i = Integer.parseInt("+10");
> -        harness.check(true);
> -	harness.check(i, 10);
> -      }
> -    catch (NumberFormatException nfe)
> -      {
> -    	harness.fail("Leading '+' does not throw NumberFormatException");
> +    // it means that the following step should be divided
> +    // for pre JDK1.7 case and >= JDK1.7
> +    if (conformToJDK17()) {
> +      try
> +        {
> +          i = Integer.parseInt("+10");
> +          harness.check(true);
> +          harness.check(i, 10);
> +        }
> +      catch (NumberFormatException nfe)
> +        {
> +          harness.fail("'+10' string is not parsed correctly as expected in JDK1.7");
> +        }
> +      }
> +    else { // pre JDK1.7 branch
> +      try
> +        {
> +          i = Integer.parseInt("+10");
> +          harness.fail("'+10' must throw NumberFormatException");
> +        }
> +      catch (NumberFormatException nfe)
> +        {
> +          harness.check(true);
> +        }
>        }
>  
>      try


-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

Support Free Java!
Contribute to GNU Classpath and IcedTea
http://www.gnu.org/software/classpath
http://icedtea.classpath.org
PGP Key: F5862A37 (https://keys.indymedia.org/)
Fingerprint = EA30 D855 D50F 90CD F54D  0698 0713 C3ED F586 2A37

      reply	other threads:[~2011-08-18 15:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-17 16:19 Pavel Tisnovsky
2011-08-17 16:27 ` Dr Andrew John Hughes
2011-08-18  8:12   ` Pavel Tisnovsky
2011-08-18 15:50     ` Dr Andrew John Hughes
2011-08-18 12:41   ` Pavel Tisnovsky
2011-08-18 15:46     ` Dr Andrew John Hughes [this message]

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=20110818154546.GF9583@rivendell.middle-earth.co.uk \
    --to=ahughes@redhat.com \
    --cc=mauve-discuss@sourceware.org \
    --cc=ptisnovs@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).