ICU-13162 Tweaking ignorables handling to round-trip new fa percent pattern.

X-SVN-Rev: 40093
This commit is contained in:
Shane Carr 2017-05-02 00:02:43 +00:00
parent ff5e1bfd6b
commit b10a17be24
2 changed files with 9 additions and 13 deletions

View File

@ -2187,9 +2187,8 @@ public class Parse {
// Runs of ignorables (whitespace and bidi control marks) can occur at the beginning, middle,
// or end of the reference string, or a run across the entire string.
//
// - A run at the beginning is treated as if it did not exist; we let the main loop accept
// ignorables in this case.
// - A run in the middle corresponds to a run of length *zero or more* in the input.
// - A run at the beginning or in the middle corresponds to a run of length *zero or more*
// in the input.
// - A run at the end need to be matched exactly.
// - A string that contains only ignorable characters also needs to be matched exactly.
//
@ -2250,14 +2249,8 @@ public class Parse {
// RETURN
return 0L;
}
} else if (offsetOrTag == 0) {
// Run at beginning. Go to nonignorable cp.
// FALL THROUGH
// TODO: This branch doesn't work on affix patterns since offsetOrTag != 0 for the first
// element. This is harmless except for possible performance implications of evaluating
// the third case instead of the second.
} else {
// Run in middle.
// Run at beginning or in middle.
if (isIgnorable(cp, state)) {
// Consume the ignorable.
// RETURN

View File

@ -4985,17 +4985,20 @@ public class NumberFormatTest extends TestFmwk {
}
@Test
public void Test13088() {
public void Test13088and13162() {
ULocale loc = new ULocale("fa");
String pattern = "%\u00A0#,##0;%\u00A0-#,##0";
String pattern1 = "%\u00A0#,##0;%\u00A0-#,##0";
double num = -12.34;
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(loc);
// If the symbols ever change in locale data, please call the setters so that this test
// continues to use the old symbols.
assertEquals("Checking for expected symbols", "", symbols.getMinusSignString());
assertEquals("Checking for expected symbols", "‎٪", symbols.getPercentString());
DecimalFormat numfmt = new DecimalFormat(pattern, symbols);
DecimalFormat numfmt = new DecimalFormat(pattern1, symbols);
expect2(numfmt, num, "‎٪ ‎−۱٬۲۳۴");
String pattern2 = "%#,##0;%-#,##0";
numfmt = new DecimalFormat(pattern2, symbols);
expect2(numfmt, num, "‎٪‎−۱٬۲۳۴");
}
@Test