harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r414834 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/org/apache/harmony/luni/util/FloatingPointParser.java test/java/tests/api/java/lang/DoubleTest.java
Date Fri, 16 Jun 2006 14:27:29 GMT
Author: hindessm
Date: Fri Jun 16 07:27:29 2006
New Revision: 414834

URL: http://svn.apache.org/viewvc?rev=414834&view=rev
Log:
Applying patch from "[#HARMONY-489] new Double("1E+-20") should throw
exception but doesn't"

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java?rev=414834&r1=414833&r2=414834&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/util/FloatingPointParser.java
Fri Jun 16 07:27:29 2006
@@ -111,10 +111,23 @@
 			if (end + 1 == length)
 				throw new NumberFormatException(s);
 
-			if (s.charAt(end + 1) == '+')
-				e = Integer.parseInt(s.substring(end + 2, length));
-			else
-				e = Integer.parseInt(s.substring(end + 1, length));
+                        int exponent_offset = end + 1;
+                        if (s.charAt(exponent_offset) == '+') {
+                                if (s.charAt(exponent_offset + 1) == '-') {
+                                        throw new NumberFormatException(s);
+                                }
+                                exponent_offset++; // skip the plus sign
+                        }
+			try {
+				e = Integer.parseInt(s.substring(exponent_offset,
+                                                                 length));
+                        } catch (NumberFormatException ex) {
+                                // ex contains the exponent substring
+                                // only so throw a new exception with
+                                // the correct string
+				throw new NumberFormatException(s);
+                        }                            
+                                    
 		} else {
 			end = length;
 		}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java?rev=414834&r1=414833&r2=414834&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/DoubleTest.java
Fri Jun 16 07:27:29 2006
@@ -303,6 +303,14 @@
 		Double d = new Double("39089.88888888888888888888888888888888");
 		assertEquals("Created incorrect double",
 				39089.88888888888888888888888888888888, d.doubleValue());
+
+                // REGRESSION for HARMONY-489
+                try {
+                        d = new Double("1E+-20");
+                        fail("new Double(\"1E+-20\") should throw exception");
+                } catch (NumberFormatException e) {
+                        // expected
+                }
 	}
 
 	/**



Mime
View raw message