a0bd6602c3
Remove test expectations whose behavior is not specified or contradicts the Stage 3 PR https://github.com/tc39/ecma402/pull/349 which we plan to land soon. The Chinese calendar (and other calendars) now need to choose different patterns for non-default calendars to support the correct behavior. Bug: v8:9320 Change-Id: Ia84e0eb1f7244b0d2d252071cf985d97f2acec58 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1838437 Commit-Queue: Frank Tang <ftang@chromium.org> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Cr-Commit-Position: refs/heads/master@{#64149}
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
const d = new Date(2018, 5, 21); // 2018-06-21
|
|
|
|
function checkFormat(locale, options, expected) {
|
|
let df = new Intl.DateTimeFormat(locale, options);
|
|
let resolvedOptions = df.resolvedOptions();
|
|
assertEquals(expected.cal, resolvedOptions.calendar);
|
|
assertEquals(expected.numSys, resolvedOptions.numberingSystem);
|
|
|
|
let formattedParts = df.formatToParts(d);
|
|
let formattedReconstructedFromParts = formattedParts.map((part) => part.value)
|
|
.reduce((accumulated, part) => accumulated + part);
|
|
let formatted = df.format(d);
|
|
|
|
assertEquals(formatted, formattedReconstructedFromParts);
|
|
assertEquals(expected.types, formattedParts.map((part) => part.type));
|
|
assertEquals(expected.formatted, formatted);
|
|
}
|
|
|
|
[
|
|
["en", "gregory", "latn", "2018"],
|
|
["en-GB", "gregory", "latn", "2018"],
|
|
].forEach(function(entry) {
|
|
checkFormat(entry[0], {year: 'numeric'},
|
|
{ cal: entry[1],
|
|
numSys: entry[2],
|
|
formatted: entry[3],
|
|
types: ["year"],
|
|
});
|
|
});
|
|
|
|
const enUSTypes = ["month", "literal", "day", "literal", "year"];
|
|
const enGBTypes = ["day", "literal", "month", "literal", "year"];
|
|
|
|
[
|
|
["en", "gregory", "latn", "6/21/2018", enUSTypes],
|
|
["en-GB", "gregory", "latn", "21/06/2018", enGBTypes],
|
|
["en-u-nu-deva", "gregory", "deva", "६/२१/२०१८", enUSTypes],
|
|
].forEach(function(entry) {
|
|
checkFormat(entry[0], {},
|
|
{ cal: entry[1],
|
|
numSys: entry[2],
|
|
formatted: entry[3],
|
|
types: entry[4],
|
|
});
|
|
});
|