Skip to content
Permalink
Browse files
Several internationalization tests broken with ICU 69.1
https://bugs.webkit.org/show_bug.cgi?id=239724

Patch by Michael Catanzaro <mcatanzaro@gnome.org> on 2022-04-26
Reviewed by Ross Kirsling and Yusuke Suzuki.

Update these tests to be more permissive of different results for different ICU versions.
ICU 69 on macOS is producing different results from ICU 69 on Linux for reasons unexplained,
so instead of checking the version number, let's instead just accept both ways.

* stress/array-toLocaleString.js:
(shouldBeOneOf):
* stress/date-toLocaleString.js:
(shouldBeOneOf):
* stress/intl-datetimeformat-formatrange-relevant-extensions-ja.js:
(shouldBeOneOf):
(vm.icuVersion):
(shouldBeOneOfThem): Deleted.
* stress/intl-datetimeformat-formatrangetoparts-relevant-extensions-ja.js:
(shouldBeOneOf):
* stress/intl-datetimeformat.js:
(shouldBeOneOf):
(shouldBeOneOfThem): Deleted.
* stress/intl-locale-info.js:
(shouldBeOneOf):
(shouldBe):
* stress/intl-locale.js:
(shouldBeOneOf):

Canonical link: https://commits.webkit.org/250000@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@293445 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
mcatanzaro authored and webkit-commit-queue committed Apr 26, 2022
1 parent 533cbe2 commit 0eac6eab0d28628d45c31b05a2f5699af8a783b9
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 53 deletions.
@@ -1,3 +1,33 @@
2022-04-26 Michael Catanzaro <mcatanzaro@redhat.com>

Several internationalization tests broken with ICU 69.1
https://bugs.webkit.org/show_bug.cgi?id=239724

Reviewed by Ross Kirsling and Yusuke Suzuki.

Update these tests to be more permissive of different results for different ICU versions.
ICU 69 on macOS is producing different results from ICU 69 on Linux for reasons unexplained,
so instead of checking the version number, let's instead just accept both ways.

* stress/array-toLocaleString.js:
(shouldBeOneOf):
* stress/date-toLocaleString.js:
(shouldBeOneOf):
* stress/intl-datetimeformat-formatrange-relevant-extensions-ja.js:
(shouldBeOneOf):
(vm.icuVersion):
(shouldBeOneOfThem): Deleted.
* stress/intl-datetimeformat-formatrangetoparts-relevant-extensions-ja.js:
(shouldBeOneOf):
* stress/intl-datetimeformat.js:
(shouldBeOneOf):
(shouldBeOneOfThem): Deleted.
* stress/intl-locale-info.js:
(shouldBeOneOf):
(shouldBe):
* stress/intl-locale.js:
(shouldBeOneOf):

2022-04-24 Zan Dobersek <zdobersek@igalia.com>

Skip microbenchmarks/memcpy-wasm.js and friends on non-FTL (i.e. non-WASM) platforms
@@ -3,6 +3,11 @@ function shouldBe(actual, expected) {
throw new Error(`expected ${expected} but got ${actual}`);
}

function shouldBeOneOf(actual, expectedArray) {
if (!expectedArray.some((value) => value === actual))
throw new Error('bad value: ' + actual + ' expected values: ' + expectedArray);
}

function shouldThrow(func, errorType) {
let error;
try {
@@ -38,4 +43,4 @@ shouldBe([ undefined, undefined ].toLocaleString(), ',');

// Test that parameters are passed through properly.
shouldThrow(() => [ new Date ].toLocaleString('i'), RangeError);
shouldBe([ new Date(NaN), new Date(0) ].toLocaleString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), $vm.icuVersion() >= 69 ? 'Invalid Date,一九七〇/一/一 〇〇:〇〇:〇〇' : 'Invalid Date,一九七〇/一/一 上午一二:〇〇:〇〇');
shouldBeOneOf([ new Date(NaN), new Date(0) ].toLocaleString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), [ 'Invalid Date,一九七〇/一/一 〇〇:〇〇:〇〇', 'Invalid Date,一九七〇/一/一 上午一二:〇〇:〇〇' ]);
@@ -3,6 +3,11 @@ function shouldBe(actual, expected) {
throw new Error(`expected ${expected} but got ${actual}`);
}

function shouldBeOneOf(actual, expectedArray) {
if (!expectedArray.some((value) => value === actual))
throw new Error('bad value: ' + actual + ' expected values: ' + expectedArray);
}

function shouldNotThrow(func) {
func();
}
@@ -44,8 +49,8 @@ shouldBe(new Date(NaN).toLocaleString(), "Invalid Date");
// Test for DateTimeFormat behavior.
// Test that locale parameter is passed through properly.
shouldThrow(() => new Date().toLocaleString('i'), RangeError);
shouldBe(new Date(0).toLocaleString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), $vm.icuVersion() >= 69 ? '一九七〇/一/一 〇〇:〇〇:〇〇' : '一九七〇/一/一 上午一二:〇〇:〇〇');
shouldBe(new Date(0).toLocaleString('zh-Hans-CN', { timeZone: 'UTC', numberingSystem: 'hanidec' }), $vm.icuVersion() >= 69 ? '一九七〇/一/一 〇〇:〇〇:〇〇' : '一九七〇/一/一 上午一二:〇〇:〇〇');
shouldBeOneOf(new Date(0).toLocaleString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), [ '一九七〇/一/一 〇〇:〇〇:〇〇', '一九七〇/一/一 上午一二:〇〇:〇〇' ]);
shouldBeOneOf(new Date(0).toLocaleString('zh-Hans-CN', { timeZone: 'UTC', numberingSystem: 'hanidec' }), [ '一九七〇/一/一 〇〇:〇〇:〇〇', '一九七〇/一/一 上午一二:〇〇:〇〇' ]);
shouldBe(new Date(0).toLocaleString('en-u-ca-chinese', { timeZone: 'UTC', year: 'numeric' }), '1969(ji-you)');
shouldBe(new Date(0).toLocaleString('en', { timeZone: 'UTC', year: 'numeric', calendar: 'chinese' }), '1969(ji-you)');

@@ -124,8 +129,8 @@ shouldBe(new Date(NaN).toLocaleTimeString(), 'Invalid Date');
// Test for DateTimeFormat behavior.
// Test that locale parameter is passed through properly.
shouldThrow(() => new Date().toLocaleTimeString('i'), RangeError);
shouldBe(new Date(0).toLocaleTimeString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), $vm.icuVersion() >= 69 ? "〇〇:〇〇:〇〇" : "上午一二:〇〇:〇〇");
shouldBe(new Date(0).toLocaleTimeString('zh-Hans-CN', { timeZone: 'UTC', numberingSystem: 'hanidec' }), $vm.icuVersion() >= 69 ? "〇〇:〇〇:〇〇" : "上午一二:〇〇:〇〇");
shouldBeOneOf(new Date(0).toLocaleTimeString('zh-Hans-CN-u-nu-hanidec', { timeZone: 'UTC' }), [ "〇〇:〇〇:〇〇", "上午一二:〇〇:〇〇" ]);
shouldBeOneOf(new Date(0).toLocaleTimeString('zh-Hans-CN', { timeZone: 'UTC', numberingSystem: 'hanidec' }), [ "〇〇:〇〇:〇〇", "上午一二:〇〇:〇〇" ]);
shouldBe(new Date(0).toLocaleTimeString('en-u-ca-chinese', { timeZone: 'UTC', year: 'numeric' }), '1969(ji-you), 12:00:00 AM');
shouldBe(new Date(0).toLocaleTimeString('en', { timeZone: 'UTC', year: 'numeric', calendar: 'chinese' }), '1969(ji-you), 12:00:00 AM');

@@ -9,7 +9,7 @@ function shouldBe(actual, expected) {
throw new Error('bad value: ' + actual + ' expected value: ' + expected);
}

function shouldBeOneOfThem(actual, expectedArray) {
function shouldBeOneOf(actual, expectedArray) {
// Tolerate different space characters used by different ICU versions.
// Older ICU uses U+2009 Thin Space in ranges, whereas newer ICU uses
// regular old U+0020. Let's ignore these differences.
@@ -71,7 +71,7 @@ if ($vm.icuVersion() >= 64) {
timeZone: 'America/Los_Angeles',
calendar: 'chinese'
});
shouldBe(fmt2.format(date1), $vm.icuVersion() >= 69 ? `丙戌-11-22 2:00` : `丙戌年11月22日 2:00`);
shouldBeOneOf(fmt2.format(date1), [ `丙戌-11-22 2:00`, `丙戌年11月22日 2:00` ]);
shouldBe(fmt2.formatRange(date1, date2), `丙戌年11月22日 2時00分~3時00分`);
shouldBe(fmt2.formatRange(date1, date3), `丙戌年11月22日 2:00~丙戌年12月2日 2:00`);

@@ -107,11 +107,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt5.format(date1), `07/1/10 10:00`);
shouldBe(fmt5.format(date8), `07/1/11 24:00`);
shouldBeOneOfThem(fmt5.formatRange(date1, date2), [ `07/1/10 10:00~11:00`, `07/1/10 10時00分~11時00分` ]);
shouldBeOneOf(fmt5.formatRange(date1, date2), [ `07/1/10 10:00~11:00`, `07/1/10 10時00分~11時00分` ]);
shouldBe(fmt5.formatRange(date1, date3), `07/1/10 10:00~07/1/20 10:00`);
shouldBeOneOfThem(fmt5.formatRange(date1, date5), [ `07/1/10 10:00~12:00`, `07/1/10 10時00分~12時00分` ]);
shouldBeOneOfThem(fmt5.formatRange(date1, date6), [ `07/1/10 10:00~14:00`, `07/1/10 10時00分~14時00分` ]);
shouldBeOneOfThem(fmt5.formatRange(date1, date7), [ `07/1/10 10:00~23:00`, `07/1/10 10時00分~23時00分` ]);
shouldBeOneOf(fmt5.formatRange(date1, date5), [ `07/1/10 10:00~12:00`, `07/1/10 10時00分~12時00分` ]);
shouldBeOneOf(fmt5.formatRange(date1, date6), [ `07/1/10 10:00~14:00`, `07/1/10 10時00分~14時00分` ]);
shouldBeOneOf(fmt5.formatRange(date1, date7), [ `07/1/10 10:00~23:00`, `07/1/10 10時00分~23時00分` ]);
if ($vm.icuVersion() > 66)
shouldBe(fmt5.formatRange(date1, date8), `07/1/10 10:00~07/1/11 24:00`);

@@ -144,11 +144,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt7.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt7.format(date8), `07/1/11 午前0:00`);
shouldBeOneOfThem(fmt7.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOfThem(fmt7.formatRange(date1, date3), [ `07/1/10 午前10:00~07/1/20 午前10:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt7.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt7.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt7.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt7.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt7.formatRange(date1, date3), [ `07/1/10 午前10:00~07/1/20 午前10:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt7.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt7.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt7.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt7.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);

let fmt8 = new Intl.DateTimeFormat("ja", {
@@ -182,11 +182,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt9.format(date1), `07/1/10 10:00`);
shouldBe(fmt9.format(date8), `07/1/11 24:00`);
shouldBeOneOfThem(fmt9.formatRange(date1, date2), [ `07/1/10 10:00~11:00`, `07/1/10 10時00分~11時00分` ]);
shouldBeOneOf(fmt9.formatRange(date1, date2), [ `07/1/10 10:00~11:00`, `07/1/10 10時00分~11時00分` ]);
shouldBe(fmt9.formatRange(date1, date3), `07/1/10 10:00~07/1/20 10:00`);
shouldBeOneOfThem(fmt9.formatRange(date1, date5), [ `07/1/10 10:00~12:00`, `07/1/10 10時00分~12時00分` ]);
shouldBeOneOfThem(fmt9.formatRange(date1, date6), [ `07/1/10 10:00~14:00`, `07/1/10 10時00分~14時00分` ]);
shouldBeOneOfThem(fmt9.formatRange(date1, date7), [ `07/1/10 10:00~23:00`, `07/1/10 10時00分~23時00分` ]);
shouldBeOneOf(fmt9.formatRange(date1, date5), [ `07/1/10 10:00~12:00`, `07/1/10 10時00分~12時00分` ]);
shouldBeOneOf(fmt9.formatRange(date1, date6), [ `07/1/10 10:00~14:00`, `07/1/10 10時00分~14時00分` ]);
shouldBeOneOf(fmt9.formatRange(date1, date7), [ `07/1/10 10:00~23:00`, `07/1/10 10時00分~23時00分` ]);
if ($vm.icuVersion() > 66)
shouldBe(fmt9.formatRange(date1, date8), `07/1/10 10:00~07/1/11 24:00`);

@@ -219,11 +219,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt11.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt11.format(date8), `07/1/11 午前00:00`);
shouldBeOneOfThem(fmt11.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt11.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBe(fmt11.formatRange(date1, date3), `07/1/10 午前10:00~07/1/20 午前10:00`);
shouldBeOneOfThem(fmt11.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt11.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt11.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt11.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt11.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt11.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt11.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);

let fmt12 = new Intl.DateTimeFormat("ja", {
@@ -258,11 +258,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt13.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt13.format(date8), `07/1/11 午前00:00`);
shouldBeOneOfThem(fmt13.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt13.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBe(fmt13.formatRange(date1, date3), `07/1/10 午前10:00~07/1/20 午前10:00`);
shouldBeOneOfThem(fmt13.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt13.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt13.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt13.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt13.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt13.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt13.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);

let fmt14 = new Intl.DateTimeFormat("ja", {
@@ -277,11 +277,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt14.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt14.format(date8), `07/1/11 午前00:00`);
shouldBeOneOfThem(fmt14.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt14.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBe(fmt14.formatRange(date1, date3), `07/1/10 午前10:00~07/1/20 午前10:00`);
shouldBeOneOfThem(fmt14.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt14.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt14.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt14.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt14.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt14.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt14.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);

let fmt15 = new Intl.DateTimeFormat("ja", {
@@ -296,11 +296,11 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt15.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt15.format(date8), `07/1/11 午前00:00`);
shouldBeOneOfThem(fmt15.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt15.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBe(fmt15.formatRange(date1, date3), `07/1/10 午前10:00~07/1/20 午前10:00`);
shouldBeOneOfThem(fmt15.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt15.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt15.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt15.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt15.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt15.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt15.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);

let fmt16 = new Intl.DateTimeFormat("ja", {
@@ -315,10 +315,10 @@ if ($vm.icuVersion() >= 64) {
});
shouldBe(fmt16.format(date1), `07/1/10 午前10:00`);
shouldBe(fmt16.format(date8), `07/1/11 午前00:00`);
shouldBeOneOfThem(fmt16.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBeOneOf(fmt16.formatRange(date1, date2), [ `07/1/10 午前10:00~午前11:00`, `07/1/10 午前10時00分~11時00分` ]);
shouldBe(fmt16.formatRange(date1, date3), `07/1/10 午前10:00~07/1/20 午前10:00`);
shouldBeOneOfThem(fmt16.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOfThem(fmt16.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOfThem(fmt16.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBeOneOf(fmt16.formatRange(date1, date5), [ `07/1/10 午前10:00~午後0:00`, `07/1/10 午前10時00分~午後0時00分` ]);
shouldBeOneOf(fmt16.formatRange(date1, date6), [ `07/1/10 午前10:00~午後2:00`, `07/1/10 午前10時00分~午後2時00分` ]);
shouldBeOneOf(fmt16.formatRange(date1, date7), [ `07/1/10 午前10:00~午後11:00`, `07/1/10 午前10時00分~午後11時00分` ]);
shouldBe(fmt16.formatRange(date1, date8), `07/1/10 午前10:00~07/1/11 午前0:00`);
}
@@ -13,6 +13,12 @@ function shouldBe(actual, expected) {
throw new Error('bad value: ' + actual + ' expected value: ' + expected);
}

function shouldBeOneOf(actual, expectedArray) {
actual = normalize(actual);
if (!expectedArray.some((value) => value === actual))
throw new Error('bad value: ' + actual + ' expected values: ' + expectedArray);
}

function compareParts(actual, expected) {
if (actual.length !== expected.length)
return false;
@@ -133,7 +139,7 @@ if (Intl.DateTimeFormat.prototype.formatRangeToParts) {
timeZone: 'America/Los_Angeles',
calendar: 'chinese'
});
shouldBe(fmt2.format(date1), $vm.icuVersion() >= 69 ? `丙戌-11-22 2:00` : `丙戌年11月22日 2:00`);
shouldBeOneOf(fmt2.format(date1), [ `丙戌-11-22 2:00`, `丙戌年11月22日 2:00` ]);
shouldBeParts(fmt2.formatRangeToParts(date1, date2), [
{"type":"yearName","value":"丙戌","source":"shared"},
{"type":"literal","value":"年","source":"shared"},

0 comments on commit 0eac6ea

Please sign in to comment.