From cd3b2c7d418917982f13a20b0668cd8696e12cab Mon Sep 17 00:00:00 2001 From: Shane Carr Date: Sat, 14 Apr 2018 06:17:39 +0000 Subject: [PATCH] ICU-13634 Updating Java test expectations with new behavior for fallback currency display. Other minor ICU4J test updates. All ICU4J tests are passing. X-SVN-Rev: 41228 --- icu4c/source/i18n/number_decimalquantity.cpp | 3 ++- .../icu/impl/number/CustomSymbolCurrency.java | 4 ---- .../number/DecimalQuantity_AbstractBCD.java | 5 +++-- .../icu/number/SkeletonSyntaxException.java | 18 +++++++++++++++++- .../format/NumberFormatRegressionTest.java | 4 ++-- .../dev/test/format/NumberRegressionTests.java | 17 ++++++++++++----- .../icu/dev/test/format/TestMessageFormat.java | 9 +++++---- .../test/serializable/ExceptionHandler.java | 12 ++++++++++++ .../serializable/SerializableTestUtility.java | 1 + 9 files changed, 54 insertions(+), 19 deletions(-) diff --git a/icu4c/source/i18n/number_decimalquantity.cpp b/icu4c/source/i18n/number_decimalquantity.cpp index baae9b76321..c61cd82e32f 100644 --- a/icu4c/source/i18n/number_decimalquantity.cpp +++ b/icu4c/source/i18n/number_decimalquantity.cpp @@ -245,7 +245,8 @@ double DecimalQuantity::getPluralOperand(PluralOperand operand) const { switch (operand) { case PLURAL_OPERAND_I: - return static_cast(toLong()); + // Invert the negative sign if necessary + return static_cast(isNegative() ? -toLong() : toLong()); case PLURAL_OPERAND_F: return static_cast(toFractionLong(true)); case PLURAL_OPERAND_T: diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/CustomSymbolCurrency.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/CustomSymbolCurrency.java index a04170b6256..bf43ccfff4b 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/CustomSymbolCurrency.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/CustomSymbolCurrency.java @@ -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); } diff --git a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java index 160c4fd1f80..7cb9bb1b15a 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/impl/number/DecimalQuantity_AbstractBCD.java @@ -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; diff --git a/icu4j/main/classes/core/src/com/ibm/icu/number/SkeletonSyntaxException.java b/icu4j/main/classes/core/src/com/ibm/icu/number/SkeletonSyntaxException.java index 92ba548eb49..d749c659435 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/number/SkeletonSyntaxException.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/number/SkeletonSyntaxException.java @@ -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); } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java index 466a8124d51..c07161b10a0 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberFormatRegressionTest.java @@ -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()); } } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java index 0b163c8a7b5..af4eb3e54c8 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/NumberRegressionTests.java @@ -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 diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TestMessageFormat.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TestMessageFormat.java index 9c3b1099043..83dc828937f 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TestMessageFormat.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/TestMessageFormat.java @@ -443,16 +443,17 @@ public class TestMessageFormat extends TestFmwk { String formatStr = "At