]> granicus.if.org Git - icu/commitdiff
ICU-13177 Merging trunk to branch
authorShane Carr <shane@unicode.org>
Thu, 24 Aug 2017 05:56:16 +0000 (05:56 +0000)
committerShane Carr <shane@unicode.org>
Thu, 24 Aug 2017 05:56:16 +0000 (05:56 +0000)
X-SVN-Rev: 40350

1  2 
icu4c/source/test/testdata/numberformattestspecification.txt
icu4j/main/classes/core/src/com/ibm/icu/impl/number/formatters/ScientificFormat.java
icu4j/main/classes/core/src/com/ibm/icu/text/DecimalFormatSymbols.java
icu4j/main/tests/core/src/com/ibm/icu/dev/data/numberformattestspecification.txt
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/IntlTestDecimalFormatSymbols.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatDataDrivenTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatTest.java

index 005158e024e84850a1f157900c7ef5c8c1683cd8,fe262fa1f9b876c7c4520dde690fd7576c05150e..88904897e74d1ad8d2b9b59bb7324ef2e05cd342
@@@ -356,13 -356,12 +356,11 @@@ minIntegerDigits        maxIntegerDigits        minFr
  // JDK gives E0
  // S obeys the maximum integer digits
  0     0       1       0       2.99792458E8    KS
 -// JDK gives .2998E9
 -0     0       0       4       2.998E8 KS
 -// According to the spec, if maxInt>minInt and minInt>1, then set
 -// minInt to 1 for the purposes of engineering notation; see #13289
 +// JDK and S give .2998E9
 +0     0       0       4       2.998E8 KSQ
- // S correctly formats this as 29.979246E7.
  // JDK uses 8 + 6 for significant digits instead of 2 + 6
- // J and C return 2.9979246E8.
- // TODO: Merge trunk
- 2     8       1       6       29.979246E7     CJKQ
++// Context: #13289
+ 2     8       1       6       2.9979246E8     K
  // Treat max int digits > 8 as being the same as min int digits.
  // This behavior is not spelled out in the specification.
  // JDK fails here because it tries to use 9 + 6 = 15 sig digits.
index 005158e024e84850a1f157900c7ef5c8c1683cd8,fe262fa1f9b876c7c4520dde690fd7576c05150e..d6385cd1beeee80a7ba2837f60b873532e363096
@@@ -356,13 -356,12 +356,11 @@@ minIntegerDigits        maxIntegerDigits        minFr
  // JDK gives E0
  // S obeys the maximum integer digits
  0     0       1       0       2.99792458E8    KS
 -// JDK gives .2998E9
 -0     0       0       4       2.998E8 KS
 +// JDK and S give .2998E9
 +0     0       0       4       2.998E8 KSQ
- // S correctly formats this as 29.979246E7.
- // JDK uses 8 + 6 for significant digits instead of 2 + 6
- // J and C return 2.9979246E8.
- // TODO: Merge trunk
- 2     8       1       6       29.979246E7     CJKQ
+ // According to the spec, if maxInt>minInt and minInt>1, then set
 -// minInt to 1 for the purposes of engineering notation; see #13289
 -// JDK uses 8 + 6 for significant digits instead of 2 + 6
++// Context: #13289
+ 2     8       1       6       2.9979246E8     K
  // Treat max int digits > 8 as being the same as min int digits.
  // This behavior is not spelled out in the specification.
  // JDK fails here because it tries to use 9 + 6 = 15 sig digits.
index 475577266eccd17c02096784358c788946818808,360f3f2e9043d770c85249427fecc10868c1d49d..bbff8be52d68df02ab63dece35bb81e7a287c00e
@@@ -319,8 -308,41 +320,44 @@@ public class IntlTestDecimalFormatSymbo
          if (!Arrays.equals(symbols.getDigitStrings(), defDigitStrings)) {
              errln("ERROR: Latin digits should be set" + symbols.getDigitStrings()[0]);
          }
 +        if (defZero != symbols.getCodePointZero()) {
 +            errln("ERROR: Code point zero be ASCII 0");
 +        }
      }
+     @Test
+     public void testNumberingSystem() {
+         Object[][] cases = {
+                 {"en", "latn", "1,234.56", ';'},
+                 {"en", "arab", "١٬٢٣٤٫٥٦", '؛'},
+                 {"en", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'},
+                 {"en", "mymr", "၁,၂၃၄.၅၆", ';'},
+                 {"my", "latn", "1,234.56", ';'},
+                 {"my", "arab", "١٬٢٣٤٫٥٦", '؛'},
+                 {"my", "mathsanb", "𝟭,𝟮𝟯𝟰.𝟱𝟲", ';'},
+                 {"my", "mymr", "၁,၂၃၄.၅၆", '၊'},
+                 {"en@numbers=thai", "mymr", "၁,၂၃၄.၅၆", ';'}, // conflicting numbering system
+         };
+         for (Object[] cas : cases) {
+             ULocale loc = new ULocale((String) cas[0]);
+             NumberingSystem ns = NumberingSystem.getInstanceByName((String) cas[1]);
+             String expectedFormattedNumberString = (String) cas[2];
+             char expectedPatternSeparator = (Character) cas[3];
+             DecimalFormatSymbols dfs = DecimalFormatSymbols.forNumberingSystem(loc, ns);
+             DecimalFormat df = new DecimalFormat("#,##0.##", dfs);
+             String actual1 = df.format(1234.56);
+             assertEquals("1234.56 with " + loc + " and " + ns.getName(),
+                     expectedFormattedNumberString, actual1);
+             // The pattern separator is something that differs by numbering system in my@numbers=mymr.
+             char actual2 = dfs.getPatternSeparator();
+             assertEquals("Pattern separator with " + loc + " and " + ns.getName(),
+                     expectedPatternSeparator, actual2);
+             // Coverage for JDK Locale overload
+             DecimalFormatSymbols dfs2 = DecimalFormatSymbols.forNumberingSystem(loc.toLocale(), ns);
+             assertEquals("JDK Locale and ICU Locale should produce the same object", dfs, dfs2);
+         }
+     }
  }
index 8cd8d2a632007b73187a998da6d1e3c3e70b5686,8573f42973bbf47cb2242afb30317b790b0b52c0..4c8ac78ece0f299b36035c1c2edbc52402bfde5d
@@@ -830,8 -787,10 +830,11 @@@ public class NumberFormatDataDrivenTes
    }
  
    @Test
 +  @Ignore
    public void TestDataDrivenJDK() {
+     // Android implements java.text.DecimalFormat with ICU4J (ticket #13322).
+     if (TestUtil.getJavaVendor() == TestUtil.JavaVendor.Android) return;
      DataDrivenNumberFormatTestUtility.runFormatSuiteIncludingKnownFailures(
          "numberformattestspecification.txt", JDK);
    }
index c67a916ff5f59771332dbc01b82470d949a2820a,21c190c5e8236dde9739582190ea946d09a73c19..697002ad2e25759e82785d0579aeb691314c2abd
@@@ -5223,19 -5227,13 +5223,26 @@@ public class NumberFormatTest extends T
          }
      }
  
 +    @Test
 +    public void Test13148() {
 +        if (logKnownIssue("13148", "Currency separators used in non-currency parsing")) return;
 +        DecimalFormat fmt = (DecimalFormat)NumberFormat.getInstance(new ULocale("en", "ZA"));
 +        DecimalFormatSymbols symbols = fmt.getDecimalFormatSymbols();
 +        symbols.setDecimalSeparator('.');
 +        symbols.setGroupingSeparator(',');
 +        fmt.setDecimalFormatSymbols(symbols);
 +        ParsePosition ppos = new ParsePosition(0);
 +        Number number = fmt.parse("300,000", ppos);
 +        assertEquals("Should parse to 300000 using non-monetary separators: " + ppos, 300000L, number);
 +    }
 +
+     @Test
+     public void Test13289() {
+         DecimalFormat df = new DecimalFormat("#00.0#E0");
+         String result = df.format(0.00123);
+         assertEquals("Should ignore scientific minInt if maxInt>minInt", "1.23E-3", result);
+     }
      @Test
      public void testPercentZero() {
          DecimalFormat df = (DecimalFormat) NumberFormat.getPercentInstance();