]> granicus.if.org Git - icu/commitdiff
ICU-13634 Updating Java test expectations with new behavior for fallback currency...
authorShane Carr <shane@unicode.org>
Sat, 14 Apr 2018 06:17:39 +0000 (06:17 +0000)
committerShane Carr <shane@unicode.org>
Sat, 14 Apr 2018 06:17:39 +0000 (06:17 +0000)
X-SVN-Rev: 41228

icu4c/source/i18n/number_decimalquantity.cpp
icu4j/main/classes/core/src/com/ibm/icu/impl/number/CustomSymbolCurrency.java
icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java
icu4j/main/classes/core/src/com/ibm/icu/number/SkeletonSyntaxException.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TestMessageFormat.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/ExceptionHandler.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/serializable/SerializableTestUtility.java

index baae9b76321e378b8930ea3b32db4aaf5744631f..c61cd82e32f53add8c0c73cd945814290d588e3a 100644 (file)
@@ -245,7 +245,8 @@ double DecimalQuantity::getPluralOperand(PluralOperand operand) const {
 
     switch (operand) {
         case PLURAL_OPERAND_I:
-            return static_cast<double>(toLong());
+            // Invert the negative sign if necessary
+            return static_cast<double>(isNegative() ? -toLong() : toLong());
         case PLURAL_OPERAND_F:
             return static_cast<double>(toFractionLong(true));
         case PLURAL_OPERAND_T:
index a04170b6256a6dee6b2d3010bce3f7342a41c98d..bf43ccfff4ba502ef179be21ddb4edd23f11ac0d 100644 (file)
@@ -49,10 +49,6 @@ public class CustomSymbolCurrency extends Currency {
 
     @Override
     public String getName(ULocale locale, int nameStyle, String pluralCount, boolean[] isChoiceFormat) {
-        if (nameStyle == PLURAL_LONG_NAME && subType.equals("XXX")) {
-            // Plural in absence of a currency should return the symbol
-            return symbol1;
-        }
         return super.getName(locale, nameStyle, pluralCount, isChoiceFormat);
     }
 
index 160c4fd1f80802764b009cfb5753cba0bc9cb858..7cb9bb1b15ac3fac6209e4229379c2127fe891c2 100644 (file)
@@ -241,7 +241,8 @@ public abstract class DecimalQuantity_AbstractBCD implements DecimalQuantity {
 
         switch (operand) {
         case i:
-            return toLong();
+            // Invert the negative sign if necessary
+            return isNegative() ? -toLong() : toLong();
         case f:
             return toFractionLong(true);
         case t:
@@ -571,7 +572,7 @@ public abstract class DecimalQuantity_AbstractBCD implements DecimalQuantity {
      * Returns a long approximating the internal BCD. A long can only represent the integral part of the
      * number.
      *
-     * @return A double representation of the internal BCD.
+     * @return A 64-bit integer representation of the internal BCD.
      */
     public long toLong() {
         long result = 0L;
index 92ba548eb49b1a38db07f51279d353f41fccb9b9..d749c659435e8c62c169a081009479c18ddcf033 100644 (file)
@@ -5,15 +5,31 @@ package com.ibm.icu.number;
 /**
  * Exception used for illegal number skeleton strings.
  *
- * @author sffc
+ * @draft ICU 62
+ * @provisional This API might change or be removed in a future release.
+ * @see NumberFormatter
  */
 public class SkeletonSyntaxException extends IllegalArgumentException {
     private static final long serialVersionUID = 7733971331648360554L;
 
+    /**
+     * Construct a new SkeletonSyntaxException with information about the token at the point of failure.
+     *
+     * @draft ICU 62
+     * @provisional This API might change or be removed in a future release.
+     * @see NumberFormatter
+     */
     public SkeletonSyntaxException(String message, CharSequence token) {
         super("Syntax error in skeleton string: " + message + ": " + token);
     }
 
+    /**
+     * Construct a new SkeletonSyntaxException with information about the token at the point of failure.
+     *
+     * @draft ICU 62
+     * @provisional This API might change or be removed in a future release.
+     * @see NumberFormatter
+     */
     public SkeletonSyntaxException(String message, CharSequence token, Throwable cause) {
         super("Syntax error in skeleton string: " + message + ": " + token, cause);
     }
index 466a8124d5193a0642b349f0d4dabef380c693ad..c07161b10a0e8a666fa1940c96744e367aaa7b30 100644 (file)
@@ -393,8 +393,8 @@ public class NumberFormatRegressionTest extends TestFmwk {
         ULocale locale = new ULocale("en");
         DecimalFormat nf = (DecimalFormat) NumberFormat.getInstance(locale, NumberFormat.PLURALCURRENCYSTYLE);
         assertEquals(
-            "Positive suffix should contain the single currency sign when no currency is set",
-            " \u00A4",
+            "Positive suffix should contain the localized display name for currency XXX",
+            " (unknown currency)",
             nf.getPositiveSuffix());
     }
 }
index 0b163c8a7b5c207885e67e41988615f42e8dbe8d..af4eb3e54c8036a3d70c6541f5a0a2a0bd68c856 100644 (file)
@@ -38,6 +38,7 @@ import java.text.ParsePosition;
 import java.util.Date;
 import java.util.Locale;
 
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
@@ -49,6 +50,7 @@ import com.ibm.icu.text.DateFormat;
 import com.ibm.icu.text.DecimalFormat;
 import com.ibm.icu.text.DecimalFormatSymbols;
 import com.ibm.icu.text.NumberFormat;
+import com.ibm.icu.util.Currency;
 import com.ibm.icu.util.GregorianCalendar;
 import com.ibm.icu.util.ULocale;
 import com.ibm.icu.util.VersionInfo;
@@ -410,9 +412,7 @@ public class NumberRegressionTests extends TestFmwk {
         logln("Long.MIN_VALUE : " + df.parse(str, new ParsePosition(0)).toString());
         df.setMultiplier(100);
         Number num = df.parse(str, new ParsePosition(0));
-        if (num.doubleValue() != -9.223372036854776E16) {
-            errln("Bug 4092561 test failed when multiplier is set to not 1.");
-        }
+        assertEquals("Bug 4092561 test failed when multiplier is set to not 1.", -9.223372036854776E16, num.doubleValue());
         Locale.setDefault(savedLocale);
     }
 
@@ -998,8 +998,12 @@ public class NumberRegressionTests extends TestFmwk {
      * 1) Make sure that all currency formats use the generic currency symbol.
      * 2) Make sure we get the same results using the generic symbol or a
      *    hard-coded one.
+     *
+     * ICU 62: DecimalFormatSymbols currency symbol has long been deprecated.
+     * In the absence of a user-specified currency, XXX is used instead.
      */
     @Test
+    @Ignore
     public void Test4122840()
     {
         Locale[] locales = NumberFormat.getAvailableLocales();
@@ -1555,10 +1559,13 @@ public class NumberRegressionTests extends TestFmwk {
                 String pat = df.toPattern();
                 DecimalFormatSymbols symb = new DecimalFormatSymbols(avail[i]);
                 DecimalFormat f2 = new DecimalFormat(pat, symb);
-                f2.setCurrency(df.getCurrency()); // Currency does not travel with the pattern string
+                if (df.getCurrency() != Currency.getInstance("XXX") && j == 1) {
+                    // Currency does not travel with the pattern string
+                    f2.setCurrency(df.getCurrency());
+                }
                 if (!df.equals(f2)) {
                     errln("FAIL: " + avail[i] + " #" + j + " -> \"" + pat +
-                          "\" -> \"" + f2.toPattern() + '"');
+                          "\" -> \"" + f2.toPattern() + "\" for case " + j);
                 }
 
                 // Test toLocalizedPattern/applyLocalizedPattern round trip
index 9c3b1099043dce321d145733ea0a2ad5d6cced24..83dc828937f5a6e83c463727723555b63ae0160d 100644 (file)
@@ -443,16 +443,17 @@ public class TestMessageFormat extends TestFmwk {
         String formatStr = "At <time> on {1,date}, you made a {2} of {0,number,currency}.";
         // {sfb} to get $, would need Locale::US, not Locale::ENGLISH
         // Just use unlocalized currency symbol.
+        // ICU 62: use the unknown currency symbol XXX.
         //String compareStrEng = "At <time> on Aug 8, 1997, you made a deposit of $456.83.";
         String compareStrEng = "At <time> on Aug 8, 1997, you made a deposit of ";
-        compareStrEng += '\u00a4';
+        compareStrEng += "XXX\u00a0";
         compareStrEng += "456.83.";
         // {sfb} to get DM, would need Locale::GERMANY, not Locale::GERMAN
         // Just use unlocalized currency symbol.
         //String compareStrGer = "At <time> on 08.08.1997, you made a deposit of 456,83 DM.";
         String compareStrGer = "At <time> on 08.08.1997, you made a deposit of ";
         compareStrGer += "456,83\u00a0";
-        compareStrGer += '\u00a4';
+        compareStrGer += "XXX";
         compareStrGer += ".";
 
         MessageFormat msg = new MessageFormat(formatStr, Locale.ENGLISH);
@@ -912,12 +913,12 @@ public class TestMessageFormat extends TestFmwk {
         String compareStr = "At <time> on Aug 8, 1997, you made a deposit of $456.83.";
         // the date being German-style, but the currency being English-style
         String compareStr2 = "At <time> on 08.08.1997, you made a deposit of ";
-        compareStr2 += '\u00a4';
+        compareStr2 += "XXX\u00A0";
         compareStr2 += "456.83.";
         // both date and currency formats are German-style
         String compareStr3 = "At <time> on 08.08.1997, you made a deposit of ";
         compareStr3 += "456,83\u00a0";
-        compareStr3 += '\u00a4';
+        compareStr3 += "XXX";
         compareStr3 += ".";
 
         MessageFormat msg = new MessageFormat(formatStr, ULocale.US);
index d009c6375a7ac413b329a780c3fe3f35f30f0320..34c3c588bb3048e3693ba6cd91b43eed6ffab0c1 100644 (file)
@@ -15,6 +15,7 @@ import java.util.Locale;
 import com.ibm.icu.impl.IllegalIcuArgumentException;
 import com.ibm.icu.impl.InvalidFormatException;
 import com.ibm.icu.impl.locale.LocaleSyntaxException;
+import com.ibm.icu.number.SkeletonSyntaxException;
 import com.ibm.icu.text.ArabicShapingException;
 import com.ibm.icu.text.StringPrepParseException;
 import com.ibm.icu.util.IllformedLocaleException;
@@ -147,4 +148,15 @@ public abstract class ExceptionHandler implements SerializableTestUtility.Handle
             return exceptions;
         }
     }
+
+    static class SkeletonSyntaxExceptionHandler extends ExceptionHandler
+    {
+        public Object[] getTestObjects()
+        {
+            SkeletonSyntaxException[] exceptions = {
+                new SkeletonSyntaxException("Bad number skeleton", "[foo]")
+            };
+            return exceptions;
+        }
+    }
 }
index e0ef2f668c437658220106adaba6a5fd65cb937c..e3ffd019857d87d2552f38888d87be8a7ab63169 100644 (file)
@@ -832,6 +832,7 @@ public class SerializableTestUtility {
         map.put("com.ibm.icu.impl.number.Properties", new PropertiesTest.ICU59PropertiesHandler());
         map.put("com.ibm.icu.impl.number.DecimalFormatProperties", new PropertiesTest.PropertiesHandler());
         map.put("com.ibm.icu.impl.number.CustomSymbolCurrency", new CurrencyHandler());
+        map.put("com.ibm.icu.number.SkeletonSyntaxException", new ExceptionHandler.SkeletonSyntaxExceptionHandler());
 
         map.put("com.ibm.icu.util.ICUException", new ICUExceptionHandler());
         map.put("com.ibm.icu.util.ICUUncheckedIOException", new ICUUncheckedIOExceptionHandler());