File: jtreg-double-to-string.patch

package info (click to toggle)
openjdk-6 6b27-1.12.6-1~deb6u1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-proposed-updates
  • size: 133,540 kB
  • ctags: 37,146
  • sloc: java: 173,188; cpp: 13,710; asm: 6,470; ansic: 4,827; sh: 4,156; makefile: 4,149; perl: 1,005; python: 310
file content (48 lines) | stat: -rw-r--r-- 1,790 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--- openjdk-old/jdk/test/java/lang/Double/ToString.java	2011-02-28 10:51:09.454128000 +0100
+++ openjdk/jdk/test/java/lang/Double/ToString.java	2011-02-28 10:51:09.454128000 +0100
@@ -23,17 +23,39 @@
 
 /*
  * @test
- * @bug 4428022
+ * @bug 4428022 4511638
  * @summary Tests for Double.toString
- * @author Andrew Haley <aph@redhat.com>
+ * @author Andrew Haley <aph@redhat.com>, Pavel Tisnovsky <ptisnovs@redhat.com>
  */
 
 public class ToString {
+    private static boolean conversionFailure = false;
+
+    public static void check(double d, String str) {
+        String converted = Double.toString(d);
+        if (!converted.equals(str)) {
+            conversionFailure = true;
+            System.out.println("Double.toString(" + str + ") is not \"" + str + "\" but \"" + converted + "\"");
+        }
+        else {
+            System.out.println("Double value " + str + " converted correctly");
+        }
+    }
 
     public static void main(String args[]) {
-      if (!Double.toString(0.001).equals("0.001"))
-	  throw new RuntimeException("Double.toString(0.001) is not \"0.001\"");
-      if (!Double.toString(0.002).equals("0.002"))
-	  throw new RuntimeException("Double.toString(0.001) is not \"0.002\"");
+        check(0.001, "0.001");
+        check(0.002, "0.002");
+        check(7.79625120912E289, "7.79625120912E289");
+        check(1.0E23, "1.0E23");
+        check(9.999999999999999E22, "1.0E23");
+        check(8.41E21, "8.41E21");
+        check(2.0E23, "2.0E23");
+        check(8.962E21, "8.962E21");
+        check(7.3879E20, "7.3879E20");
+        check(3.1E22, "3.1E22");
+        check(5.63E21, "5.63E21");
+        if (conversionFailure) {
+            throw new RuntimeException("At least one conversion failure occured");
+        }
     }
 }