Fix test failures due to the ICU-52 update.
Some of the failures were due to the fact that we stopped
parsing numbers like "36-" for RTL locales, and others were
due to the fact that we were using reference equality for
comparing minusSign.
Change-Id: I239e6b8b77165a4665c554e46e6fb652beec2ec2
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
index cb7ac4b..49e3d9e 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/text/NumberFormatTest.java
@@ -174,16 +174,16 @@
format = (DecimalFormat) NumberFormat.getIntegerInstance(arLocale);
assertEquals(
"Test7: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).toPattern() returned wrong pattern",
- "#0;#0-", format.toPattern());
+ "#,##0", format.toPattern());
assertEquals(
"Test8: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).format(-35.76) returned wrong value",
- "\u0666-", format.format(-6));
+ "\u200f-\u0666", format.format(-6));
assertEquals(
"Test9: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parse(\"-36-\") returned wrong number",
- new Long(-36), format.parse("36-"));
+ new Long(36), format.parse("36-"));
assertEquals(
"Test10: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).parseObject(\"36-\") returned wrong number",
- new Long(-36), format.parseObject("36-"));
+ new Long(36), format.parseObject("36-"));
assertEquals(
"Test11: NumberFormat.getIntegerInstance(new Locale(\"ar\", \"AE\")).getMaximumFractionDigits() returned wrong value",
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LocaleTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LocaleTest.java
index 426e52c..dfb2d96 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LocaleTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/LocaleTest.java
@@ -175,7 +175,7 @@
// Regression for Harmony-1146
Locale l_countryCD = new Locale("", "CD");
- assertEquals("Congo [DRC]",
+ assertEquals("Congo (DRC)",
l_countryCD.getDisplayCountry());
}
diff --git a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java
index 585ba44..cc6a0f0 100644
--- a/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java
+++ b/harmony-tests/src/test/java/org/apache/harmony/tests/java/util/ScannerTest.java
@@ -25,9 +25,9 @@
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PipedInputStream;
@@ -39,12 +39,12 @@
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketAddress;
+import java.nio.CharBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.IllegalBlockingModeException;
import java.nio.channels.ReadableByteChannel;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
-import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
@@ -52,10 +52,9 @@
import java.util.List;
import java.util.Locale;
import java.util.NoSuchElementException;
+import java.util.Scanner;
import java.util.regex.MatchResult;
import java.util.regex.Pattern;
-import java.util.Scanner;
-
import junit.framework.TestCase;
public class ScannerTest extends TestCase {
@@ -1058,27 +1057,20 @@
s.useLocale(Locale.CHINESE);
assertEquals(12300, s.nextInt(10));
- /*
- * There are three types of negative prefix all in all. '' '-' '(' There
- * are three types of negative suffix all in all. '' '-' ')' '(' and ')'
- * must be used togethor. Prefix '-' and suffix '-' must be used
- * exclusively.
- */
-
- /*
- * According to Integer regular expression: Integer :: = ( [-+]? (*
- * Numeral ) ) | LocalPositivePrefix Numeral LocalPositiveSuffix |
- * LocalNegativePrefix Numeral LocalNegativeSuffix 123- should be
- * recognized by scanner with locale ar_AE, (123) shouble be recognized
- * by scanner with locale mk_MK. But this is not the case on RI.
- */
- s = new Scanner("-123 123- -123-");
+ s = new Scanner("-123 123-");
s.useLocale(new Locale("ar", "AE"));
- assertEquals(-123, s.nextInt(10));
- // The following test case fails on RI
- assertEquals(-123, s.nextInt(10));
+ assertEquals(-123, s.nextInt());
try {
- s.nextInt(10);
+ s.nextInt();
+ fail();
+ } catch (InputMismatchException expected) {
+ }
+
+ s = new Scanner("-123 -123-");
+ s.useLocale(new Locale("ar", "AE"));
+ assertEquals(-123, s.nextInt());
+ try {
+ s.nextInt();
fail();
} catch (InputMismatchException expected) {
}
@@ -1244,24 +1236,17 @@
s.useLocale(Locale.CHINESE);
assertEquals(12300, s.nextInt());
- /*
- * There are three types of negative prefix all in all. '' '-' '(' There
- * are three types of negative suffix all in all. '' '-' ')' '(' and ')'
- * must be used togethor. Prefix '-' and suffix '-' must be used
- * exclusively.
- */
-
- /*
- * According to Integer regular expression: Integer :: = ( [-+]? (*
- * Numeral ) ) | LocalPositivePrefix Numeral LocalPositiveSuffix |
- * LocalNegativePrefix Numeral LocalNegativeSuffix 123- should be
- * recognized by scanner with locale ar_AE, (123) shouble be recognized
- * by scanner with locale mk_MK. But this is not the case on RI.
- */
- s = new Scanner("-123 123- -123-");
+ s = new Scanner("-123 123-");
s.useLocale(new Locale("ar", "AE"));
assertEquals(-123, s.nextInt());
- // The following test case fails on RI
+ try {
+ s.nextInt();
+ fail();
+ } catch (InputMismatchException expected) {
+ }
+
+ s = new Scanner("-123 -123-");
+ s.useLocale(new Locale("ar", "AE"));
assertEquals(-123, s.nextInt());
try {
s.nextInt();
@@ -3259,26 +3244,19 @@
assertTrue(s.hasNextInt(10));
assertEquals(12300, s.nextInt(10));
- /*
- * There are three types of negative prefix all in all. '' '-' '(' There
- * are three types of negative suffix all in all. '' '-' ')' '(' and ')'
- * must be used together. Prefix '-' and suffix '-' must be used
- * exclusively.
- */
-
- /*
- * According to Integer regular expression: Integer :: = ( [-+]? (*
- * Numeral ) ) | LocalPositivePrefix Numeral LocalPositiveSuffix |
- * LocalNegativePrefix Numeral LocalNegativeSuffix 123- should be
- * recognized by scanner with locale ar_AE, (123) should be recognized
- * by scanner with locale mk_MK. But this is not the case on RI.
- */
- s = new Scanner("-123 123- -123-");
+ s = new Scanner("-123 123-");
s.useLocale(new Locale("ar", "AE"));
assertTrue(s.hasNextInt(10));
assertEquals(-123, s.nextInt(10));
- // The following test case fails on RI
- assertTrue(s.hasNextInt(10));
+ assertFalse(s.hasNextInt(10));
+ try {
+ s.nextInt(10);
+ fail();
+ } catch (InputMismatchException expected) {
+ }
+
+ s = new Scanner("-123 -123-");
+ s.useLocale(new Locale("ar", "AE"));
assertEquals(-123, s.nextInt(10));
assertFalse(s.hasNextInt(10));
try {
@@ -3452,25 +3430,19 @@
assertTrue(s.hasNextInt());
assertEquals(12300, s.nextInt());
- /*
- * There are three types of negative prefix all in all. '' '-' '(' There
- * are three types of negative suffix all in all. '' '-' ')' '(' and ')'
- * must be used togethor. Prefix '-' and suffix '-' must be used
- * exclusively.
- */
-
- /*
- * According to Integer regular expression: Integer :: = ( [-+]? (*
- * Numeral ) ) | LocalPositivePrefix Numeral LocalPositiveSuffix |
- * LocalNegativePrefix Numeral LocalNegativeSuffix 123- should be
- * recognized by scanner with locale ar_AE, (123) shouble be recognized
- * by scanner with locale mk_MK. But this is not the case on RI.
- */
- s = new Scanner("-123 123- -123-");
+ s = new Scanner("-123 123-");
s.useLocale(new Locale("ar", "AE"));
assertTrue(s.hasNextInt());
assertEquals(-123, s.nextInt());
- // The following test case fails on RI
+ assertFalse(s.hasNextInt());
+ try {
+ s.nextInt();
+ fail();
+ } catch (InputMismatchException expected) {
+ }
+
+ s = new Scanner("-123 -123-");
+ s.useLocale(new Locale("ar", "AE"));
assertTrue(s.hasNextInt());
assertEquals(-123, s.nextInt());
assertFalse(s.hasNextInt());
diff --git a/luni/src/main/java/java/text/DecimalFormatSymbols.java b/luni/src/main/java/java/text/DecimalFormatSymbols.java
index 73e0f9f..1611594 100644
--- a/luni/src/main/java/java/text/DecimalFormatSymbols.java
+++ b/luni/src/main/java/java/text/DecimalFormatSymbols.java
@@ -179,7 +179,7 @@
groupingSeparator == obj.groupingSeparator &&
infinity.equals(obj.infinity) &&
intlCurrencySymbol.equals(obj.intlCurrencySymbol) &&
- minusSign == obj.minusSign &&
+ minusSign.equals(obj.minusSign) &&
monetarySeparator == obj.monetarySeparator &&
NaN.equals(obj.NaN) &&
patternSeparator == obj.patternSeparator &&