mirror of
https://github.com/tc39/test262.git
synced 2025-07-27 16:04:36 +02:00
Test the interaction of timeStyle and u-hc locale tags. (#2144)
This commit is contained in:
parent
532206a9bd
commit
94c498a792
@ -50,26 +50,37 @@ for (const [dateStyle, expected] of dateOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const [timeStyle, expected12, expected24] of timeOptions) {
|
for (const [timeStyle, expected12, expected24] of timeOptions) {
|
||||||
for (const hourOptions of options12) {
|
const check = (locale, options, expected) => {
|
||||||
const dtf = new Intl.DateTimeFormat("en-US", {
|
const dtf = new Intl.DateTimeFormat(locale, {
|
||||||
timeStyle,
|
timeStyle,
|
||||||
timeZone: "UTC",
|
timeZone: "UTC",
|
||||||
...hourOptions
|
...options
|
||||||
});
|
});
|
||||||
|
|
||||||
const dateString = dtf.format(date);
|
const dateString = dtf.format(date);
|
||||||
assert.sameValue(dateString, expected12, `Result for ${timeStyle} with ${JSON.stringify(hourOptions)}`);
|
assert.sameValue(dateString, expected, `Result for ${timeStyle} with ${JSON.stringify(options)}`);
|
||||||
|
};
|
||||||
|
|
||||||
|
check("en-US", {}, expected12);
|
||||||
|
check("en-US-u-hc-h11", {}, expected12);
|
||||||
|
check("en-US-u-hc-h12", {}, expected12);
|
||||||
|
check("en-US-u-hc-h23", {}, expected24);
|
||||||
|
check("en-US-u-hc-h24", {}, expected24);
|
||||||
|
|
||||||
|
for (const hourOptions of options12) {
|
||||||
|
check("en-US", hourOptions, expected12);
|
||||||
|
check("en-US-u-hc-h11", hourOptions, expected12);
|
||||||
|
check("en-US-u-hc-h12", hourOptions, expected12);
|
||||||
|
check("en-US-u-hc-h23", hourOptions, expected12);
|
||||||
|
check("en-US-u-hc-h24", hourOptions, expected12);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const hourOptions of options24) {
|
for (const hourOptions of options24) {
|
||||||
const dtf = new Intl.DateTimeFormat("en-US", {
|
check("en-US", hourOptions, expected24);
|
||||||
timeStyle,
|
check("en-US-u-hc-h11", hourOptions, expected24);
|
||||||
timeZone: "UTC",
|
check("en-US-u-hc-h12", hourOptions, expected24);
|
||||||
...hourOptions
|
check("en-US-u-hc-h23", hourOptions, expected24);
|
||||||
});
|
check("en-US-u-hc-h24", hourOptions, expected24);
|
||||||
|
|
||||||
const dateString = dtf.format(date);
|
|
||||||
assert.sameValue(dateString, expected24, `Result for ${timeStyle} with ${JSON.stringify(hourOptions)}`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user