test/jdk/java/util/Calendar/Bug4958050.java
author jbhateja
Tue, 26 Nov 2019 16:09:25 +0300
changeset 59278 8375560db76b
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234394: C2: Dynamic register class support in ADLC Reviewed-by: vlivanov, sviswanathan, thartmann, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     1
/*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     2
 * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     4
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     8
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    13
 * accompanied this code).
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    14
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    18
 *
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    21
 * questions.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    22
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    23
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    24
/*
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    25
 * @test
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    26
 * @bug 4958050
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    27
 * @summary Make sure that add() and roll() handle time zone offset changes (both raw and DST) correctly.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    28
 */
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    29
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    30
import java.util.Locale;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    31
import java.util.TimeZone;
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    32
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    33
import static java.util.Calendar.*;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    34
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    35
public class Bug4958050 {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    36
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    37
    static int errorCount = 0;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    38
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    39
    public static void main(String[] args) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    40
        // All the test cases depend on historical GMT offset changes
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    41
        // of Asia/Novosibirsk.
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    42
        Koyomi cal = new Koyomi(TimeZone.getTimeZone("Asia/Novosibirsk"), Locale.US);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    43
        System.out.println("Time zone = " + cal.getTimeZone().getID());
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    44
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    45
        // Test the week fields
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    46
        int[] weekFields = {WEEK_OF_YEAR, WEEK_OF_MONTH, DAY_OF_WEEK_IN_MONTH};
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    47
        for (int i = 0; i < weekFields.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    48
            int field = weekFields[i];
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    49
            // add()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    50
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    51
            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    52
            cal.add(weekFields[i], +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    53
            if (!cal.checkDate(1919, DECEMBER, 14)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    54
                error("1919/12/07: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    55
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    56
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    57
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    58
            cal.set(1930, JUNE, 21 - 7);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    59
            cal.add(weekFields[i], +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    60
            if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    61
                error("1930/6/14: add(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    62
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    63
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    64
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    65
            // roll()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    66
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    67
            cal.set(1919, DECEMBER, 14 - 7, 23, 50, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    68
            cal.roll(weekFields[i], +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    69
            if (!cal.checkDate(1919, DECEMBER, 14)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    70
                error("1919/12/07: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    71
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    72
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    73
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    74
            cal.set(1930, JUNE, 21 - 7);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    75
            cal.roll(weekFields[i], +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    76
            if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    77
                error("1930/6/14: roll(" + Koyomi.getFieldName(weekFields[i]) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    78
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    79
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    80
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    81
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    82
        // Test the day fields
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    83
        int[] dayFields = {DAY_OF_MONTH, DAY_OF_YEAR, DAY_OF_WEEK};
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    84
        for (int i = 0; i < dayFields.length; i++) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    85
            int field = dayFields[i];
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    86
            // add()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    87
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    88
            cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    89
            cal.add(field, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    90
            if (!cal.checkDate(1919, DECEMBER, 14)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    91
                error("1919/12/13: add(" + Koyomi.getFieldName(field) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    92
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    93
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    94
            cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    95
            cal.set(1919, DECEMBER, 14, 00, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    96
            cal.add(field, -1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
    97
            if (!cal.checkDate(1919, DECEMBER, 13)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    98
                error("1919/12/14: add(" + Koyomi.getFieldName(field) + ", -1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
    99
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   100
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   101
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   102
            cal.set(1930, JUNE, 21 - 1);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   103
            cal.add(field, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   104
            if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   105
                error("1930/6/20: add(" + Koyomi.getFieldName(field) + ", +1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   106
                        + cal.getMessage() + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   107
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   108
            cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   109
            cal.set(1930, JUNE, 21, 01, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   110
            cal.add(field, -1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   111
            if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   112
                error("1930/6/21: add(" + Koyomi.getFieldName(field) + ", -1)\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   113
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   114
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   115
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   116
            // roll()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   117
            cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   118
            cal.set(1930, JUNE, 21 - 1);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   119
            int amount = +1;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   120
            if (field == DAY_OF_WEEK) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   121
                amount += 700;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   122
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   123
            cal.roll(field, amount);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   124
            if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   125
                error("1930/6/20: roll(" + Koyomi.getFieldName(field) + ", +" + amount + ")\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   126
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   127
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   128
            cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   129
            cal.set(1930, JUNE, 21, 01, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   130
            amount = -1;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   131
            if (field == DAY_OF_WEEK) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   132
                amount -= 700;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   133
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   134
            cal.roll(field, amount);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   135
            if (!cal.checkDateTime(1930, JUNE, 20, 01, 00, 00, 000)) {
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   136
                error("1930/6/21: roll(" + Koyomi.getFieldName(field) + ", " + amount + ")\n"
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   137
                        + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   138
            }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   139
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   140
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   141
        // Test the AM_PM field
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   142
        // add()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   143
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   144
        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   145
        cal.add(AM_PM, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   146
        if (!cal.checkDate(1919, DECEMBER, 14)
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   147
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   148
            error("1919/12/13: add(AM_PM, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   149
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   150
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   151
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   152
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   153
        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   154
        cal.add(AM_PM, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   155
        if (!cal.checkDate(1930, JUNE, 21)
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   156
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   157
            error("1930/6/20: add(AM_PM, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   158
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   159
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   160
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   161
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   162
        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   163
        cal.add(AM_PM, +3);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   164
        if (!cal.checkDate(1930, JUNE, 21)
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   165
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   166
            error("1930/6/10: add(AM_PM, +3)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   167
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   168
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   169
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   170
        cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   171
        cal.set(1919, DECEMBER, 14, 11, 50, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   172
        cal.add(AM_PM, -1);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   173
        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23, 50, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   174
                || !cal.checkFieldValue(AM_PM, PM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   175
            error("1919/12/14 11:50:00: add(AM_PM, -1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   176
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   177
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   178
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   179
        cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   180
        cal.set(1930, JUNE, 21, 01, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   181
        cal.add(AM_PM, -1);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   182
        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 01 + 12, 00, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   183
                || !cal.checkFieldValue(AM_PM, PM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   184
            error("1930/6/20: add(AM_PM, -1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   185
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   186
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   187
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   188
        cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   189
        cal.set(1930, JUNE, 21, 01, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   190
        cal.add(AM_PM, -3);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   191
        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 01 + 12, 00, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   192
                || !cal.checkFieldValue(AM_PM, PM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   193
            error("1930/6/10: add(AM_PM, -3)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   194
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   195
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   196
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   197
        // roll() (should NOT change the date)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   198
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   199
        cal.set(1919, DECEMBER, 14 - 1, 23, 50, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   200
        cal.roll(AM_PM, +1);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   201
        if (!cal.checkDateTime(1919, DECEMBER, 14 - 1, 23 - 12, 50, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   202
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   203
            error("1919/12/13: roll(AM_PM, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   204
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   205
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   206
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   207
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   208
        cal.set(1930, JUNE, 21 - 1, 12, 00, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   209
        cal.roll(AM_PM, +1);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   210
        if (!cal.checkDateTime(1930, JUNE, 21 - 1, 12 - 12, 00, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   211
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   212
            error("1930/6/20: roll(AM_PM, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   213
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   214
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   215
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   216
        cal.clear();
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   217
        cal.set(1930, JUNE, 21 - 2, 12, 00, 00);
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   218
        cal.roll(AM_PM, +3);
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   219
        if (!cal.checkDateTime(1930, JUNE, 21 - 2, 12 - 12, 00, 00, 000)
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   220
                || !cal.checkFieldValue(AM_PM, AM)) {
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   221
            error("1930/6/10: roll(AM_PM, +3)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   222
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   223
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   224
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   225
        // Test the HOUR_OF_DAY field
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   226
        // add()
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   227
        cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   228
        cal.set(1930, JUNE, 20, 23, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   229
        cal.add(HOUR_OF_DAY, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   230
        if (!cal.checkDateTime(1930, JUNE, 21, 01, 00, 00, 000)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   231
            error("1930/6/20 23:00:00: add(HOUR_OF_DAY, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   232
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   233
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   234
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   235
        // roll() (should NOT change the date)
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   236
        cal.clear();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   237
        cal.set(1930, JUNE, 20, 23, 00, 00);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   238
        cal.roll(HOUR_OF_DAY, +1);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   239
        if (!cal.checkDateTime(1930, JUNE, 20, 00, 00, 00, 000)) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   240
            error("1930/6/20 23:00:00: roll(HOUR_OF_DAY, +1)\n"
42159
9ab10842acf7 8165296: update existing i18n test cases of test/java/util
nishjain
parents: 38581
diff changeset
   241
                    + cal.getMessage() + " " + cal.toDateTimeString());
38581
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   242
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   243
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   244
        checkErrors();
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   245
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   246
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   247
    static void error(String s) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   248
        System.out.println(s);
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   249
        errorCount++;
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   250
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   251
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   252
    static void checkErrors() {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   253
        if (errorCount > 0) {
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   254
            throw new RuntimeException("Failed: " + errorCount + " error(s)");
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   255
        }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   256
    }
e761c1ccd13e 8031145: Re-examine closed i18n tests to see it they can be moved to the jdk repository.
okutsu
parents:
diff changeset
   257
}