From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28840 invoked by alias); 18 Aug 2011 12:41:19 -0000 Received: (qmail 28774 invoked by uid 22791); 18 Aug 2011 12:41:18 -0000 X-SWARE-Spam-Status: No, hits=-8.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Aug 2011 12:40:58 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p7ICewsH013365 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 18 Aug 2011 08:40:58 -0400 Received: from dhcp-lab-190.englab.brq.redhat.com (dhcp-2-245.brq.redhat.com [10.34.2.245]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7ICeu2b001444; Thu, 18 Aug 2011 08:40:57 -0400 Message-ID: <4E4D08C8.8010307@redhat.com> Date: Thu, 18 Aug 2011 12:41:00 -0000 From: Pavel Tisnovsky User-Agent: Thunderbird 2.0.0.23 (X11/20090825) MIME-Version: 1.0 To: Dr Andrew John Hughes CC: mauve-discuss@sourceware.org Subject: Re: Fix for test gnu/testlet/java/lang/Integer/parseInt.java References: <4E4BEA69.9040702@redhat.com> <20110817162659.GB9583@rivendell.middle-earth.co.uk> In-Reply-To: <20110817162659.GB9583@rivendell.middle-earth.co.uk> Content-Type: multipart/mixed; boundary="------------030001090408090507080903" X-IsSubscribed: yes Mailing-List: contact mauve-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: mauve-discuss-owner@sourceware.org X-SW-Source: 2011-q3/txt/msg00005.txt.bz2 This is a multi-part message in MIME format. --------------030001090408090507080903 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 366 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 --------------030001090408090507080903 Content-Type: text/x-patch; name="parseInt.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="parseInt.patch" Content-length: 1980 --- 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 --------------030001090408090507080903--