ICU-8822 commit fix from branch, include timebomb 50.0.2 against islamic/islamic-civil alias problem
X-SVN-Rev: 32132
This commit is contained in:
parent
69ae33baa3
commit
26255a3157
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2012, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -653,7 +653,11 @@ public class IslamicCalendar extends Calendar {
|
||||
* @stable ICU 3.8
|
||||
*/
|
||||
public String getType() {
|
||||
return "islamic";
|
||||
if(civil) {
|
||||
return "islamic-civil";
|
||||
} else {
|
||||
return "islamic";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 2004-2010, International Business Machines Corporation and *
|
||||
* Copyright (C) 2004-2012, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -679,8 +679,8 @@ public class GlobalizationPreferencesTest extends TestFmwk {
|
||||
gp1.setCalendar(ical);
|
||||
cal = gp1.getCalendar();
|
||||
calType = cal.getType();
|
||||
if (!calType.equals("islamic")) {
|
||||
errln("FAIL: Calendar type afte clone is " + calType + " Expected: islamic");
|
||||
if (!calType.equals("islamic-civil")) { // default constructed IslamicCalendar is islamic-civil
|
||||
errln("FAIL: Calendar type afte clone is " + calType + " Expected: islamic-civil");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -979,9 +979,7 @@ public class IBMCalendarTest extends CalendarTest {
|
||||
logln("df type: " + df.getClass().getName() + " loc: " + df.getLocale(ULocale.VALID_LOCALE));
|
||||
|
||||
Calendar cal = df.getCalendar();
|
||||
// todo, what about variants of calendars, we have a type for islamic-civil, should we also have a type
|
||||
// for variants of other calendars?
|
||||
assertEquals("calendar types", cal.getType(), calTypes[i].equals("islamic-civil") ? "islamic" : calTypes[i]);
|
||||
assertEquals("calendar types", cal.getType(), calTypes[i]);
|
||||
DateFormat df2 = cal.getDateTimeFormat(DateFormat.FULL, DateFormat.FULL, ULocale.US);
|
||||
logln("df2 type: " + df2.getClass().getName() + " loc: " + df2.getLocale(ULocale.VALID_LOCALE));
|
||||
assertEquals("format results", df.format(time), df2.format(time));
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
*******************************************************************************
|
||||
* Copyright (C) 1996-2011, International Business Machines Corporation and *
|
||||
* Copyright (C) 1996-2012, International Business Machines Corporation and *
|
||||
* others. All Rights Reserved. *
|
||||
*******************************************************************************
|
||||
*/
|
||||
@ -276,5 +276,21 @@ public class IslamicTest extends CalendarTest {
|
||||
civilCalendar.setCivil(true);
|
||||
return civilCalendar;
|
||||
}
|
||||
private static IslamicCalendar newIslamic() {
|
||||
IslamicCalendar civilCalendar = new IslamicCalendar();
|
||||
civilCalendar.setCivil(false);
|
||||
return civilCalendar;
|
||||
}
|
||||
|
||||
private void verifyType(Calendar c, String expectType) {
|
||||
String theType = c.getType();
|
||||
if(!theType.equals(expectType)) {
|
||||
errln("Expected calendar to be type " + expectType + " but instead it is " + theType);
|
||||
}
|
||||
}
|
||||
|
||||
public void Test8822() {
|
||||
verifyType(newIslamic(),"islamic");
|
||||
verifyType(newCivil(),"islamic-civil");
|
||||
}
|
||||
}
|
||||
|
@ -1089,6 +1089,7 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
|
||||
HUNGARIAN, ITALIAN, HEBREW, JAPANESE, KOREAN, POLISH, PORTUGUESE, RUSSIAN, TURKISH,
|
||||
CHINESE_SIMPLIFIED, CHINESE_TRADITIONAL };
|
||||
|
||||
String[] islamicCivilTwelfthMonthLocalized = new String[locales.length];
|
||||
String[] islamicTwelfthMonthLocalized = new String[locales.length];
|
||||
String[] gregorianTwelfthMonthLocalized = new String[locales.length];
|
||||
|
||||
@ -1097,7 +1098,19 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
|
||||
Locale locale = locales[i];
|
||||
|
||||
// Islamic
|
||||
com.ibm.icu.util.Calendar islamicCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
|
||||
com.ibm.icu.util.Calendar islamicCivilCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
|
||||
com.ibm.icu.text.SimpleDateFormat islamicCivilDateFormat = (com.ibm.icu.text.SimpleDateFormat) islamicCivilCalendar
|
||||
.getDateTimeFormat(com.ibm.icu.text.DateFormat.FULL, -1, locale);
|
||||
com.ibm.icu.text.DateFormatSymbols islamicCivilDateFormatSymbols = islamicCivilDateFormat
|
||||
.getDateFormatSymbols();
|
||||
|
||||
String[] shortMonthsCivil = islamicCivilDateFormatSymbols.getShortMonths();
|
||||
String twelfthMonthLocalizedCivil = shortMonthsCivil[11];
|
||||
|
||||
islamicCivilTwelfthMonthLocalized[i] = twelfthMonthLocalizedCivil;
|
||||
|
||||
com.ibm.icu.util.IslamicCalendar islamicCalendar = new com.ibm.icu.util.IslamicCalendar(locale);
|
||||
islamicCalendar.setCivil(false);
|
||||
com.ibm.icu.text.SimpleDateFormat islamicDateFormat = (com.ibm.icu.text.SimpleDateFormat) islamicCalendar
|
||||
.getDateTimeFormat(com.ibm.icu.text.DateFormat.FULL, -1, locale);
|
||||
com.ibm.icu.text.DateFormatSymbols islamicDateFormatSymbols = islamicDateFormat
|
||||
@ -1123,17 +1136,42 @@ public class DateFormatRegressionTest extends com.ibm.icu.dev.test.TestFmwk {
|
||||
|
||||
}
|
||||
|
||||
boolean skipIn8822 = isICUVersionBefore(50, 0, 2);
|
||||
if(skipIn8822) {
|
||||
logln("Note: some tests timebombed to go off by 50m2");
|
||||
}
|
||||
|
||||
// Compare
|
||||
for (int i = 0; i < locales.length; i++) {
|
||||
|
||||
String gregorianTwelfthMonth = gregorianTwelfthMonthLocalized[i];
|
||||
String islamicCivilTwelfthMonth = islamicCivilTwelfthMonthLocalized[i];
|
||||
String islamicTwelfthMonth = islamicTwelfthMonthLocalized[i];
|
||||
|
||||
logln(locales[i] + ": " + gregorianTwelfthMonth + ", " + islamicTwelfthMonth);
|
||||
logln(locales[i] + ": g:" + gregorianTwelfthMonth + ", ic:" + islamicCivilTwelfthMonth + ", i:"+islamicTwelfthMonth);
|
||||
if (gregorianTwelfthMonth.equalsIgnoreCase(islamicTwelfthMonth)) {
|
||||
errln(locales[i] + ": gregorian and islamic are same: " + gregorianTwelfthMonth
|
||||
+ ", " + islamicTwelfthMonth);
|
||||
}
|
||||
|
||||
if (gregorianTwelfthMonth.equalsIgnoreCase(islamicCivilTwelfthMonth)) {
|
||||
if(!skipIn8822) {
|
||||
errln(locales[i] + ": gregorian and islamic-civil are same: " + gregorianTwelfthMonth
|
||||
+ ", " + islamicCivilTwelfthMonth);
|
||||
} else {
|
||||
logln(locales[i] + ": gregorian and islamic-civil are same: " + gregorianTwelfthMonth
|
||||
+ ", " + islamicCivilTwelfthMonth + " (TIMEBOMBED until ICU 50.0.2)");
|
||||
}
|
||||
}
|
||||
if (!islamicTwelfthMonth.equalsIgnoreCase(islamicCivilTwelfthMonth)) {
|
||||
if(!skipIn8822) {
|
||||
errln(locales[i] + ": islamic-civil and islamic are NOT same: " + islamicCivilTwelfthMonth
|
||||
+ ", " + islamicTwelfthMonth);
|
||||
} else {
|
||||
logln(locales[i] + ": islamic-civil and islamic are NOT same: " + islamicCivilTwelfthMonth
|
||||
+ ", " + islamicTwelfthMonth + " (TIMEBOMBED until 50.0.2)");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user