]> granicus.if.org Git - icu/commitdiff
ICU-8822 commit fix from branch, include timebomb 50.0.2 against islamic/islamic...
authorSteven R. Loomis <srl@icu-project.org>
Wed, 8 Aug 2012 23:30:29 +0000 (23:30 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Wed, 8 Aug 2012 23:30:29 +0000 (23:30 +0000)
X-SVN-Rev: 32132

icu4j/main/classes/core/src/com/ibm/icu/util/IslamicCalendar.java
icu4j/main/tests/collate/src/com/ibm/icu/dev/test/format/GlobalizationPreferencesTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IBMCalendarTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/calendar/IslamicTest.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/DateFormatRegressionTest.java

index c6df5b78672c3d48bd892aa5319a629c6896526c..250c72c0149298c651ab87d5933e4a3ae17d5a4e 100644 (file)
@@ -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";
+        }
     }
 
     /*
index 25883c217569e5c73d09337a4e10e8de43a5f2ad..84108cee1297aef6269664aae4a2d521a4308c00 100644 (file)
@@ -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");
         }
     }
 
index 31669f99c9e307427d9d82a6086503c5ca3df6ec..b8087870b79653cb06f7aea634505d3631e7357a 100644 (file)
@@ -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));
index b2b2496e4695916aa1e72c0ec009fddf25f28135..2e5c0f5d86b14e0c8df17df42c5f20a412505355 100644 (file)
@@ -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");
+    }
 }
index 8cee984bce023d9df3a52017147551097727a244..6ca00490d383b064127267e1ff40bbce18e9e838 100644 (file)
@@ -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)");
+                }
+            }
         }
     }