mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 23:14:47 +02:00
Require correct hour-cycle setting instead of either h11 or h12 resp. h23 or h24
This commit is contained in:
parent
72db5f1ec1
commit
f65bd7af7a
@ -14,51 +14,37 @@ includes: [testIntl.js, propertyHelper.js]
|
|||||||
|
|
||||||
/* Values passed via unicode extension key work */
|
/* Values passed via unicode extension key work */
|
||||||
|
|
||||||
/**
|
const hcValues = ['h11', 'h12', 'h23', 'h24'];
|
||||||
* Since at the moment of writing, CLDR does not provide data for any locale
|
|
||||||
* that would allow it to use both 0-based and 1-based hourCycles,
|
|
||||||
* we can only test if the result is within the pair of h11/h12 or h23/h24.
|
|
||||||
*/
|
|
||||||
const hcValuePairs = [
|
|
||||||
["h11", "h12"],
|
|
||||||
["h23", "h24"]
|
|
||||||
];
|
|
||||||
|
|
||||||
const hour12Values = ['h11', 'h12'];
|
const hour12Values = ['h11', 'h12'];
|
||||||
const hour24Values = ['h23', 'h24'];
|
|
||||||
|
|
||||||
const dataPropertyDesc = { writable: true, enumerable: true, configurable: true };
|
const dataPropertyDesc = { writable: true, enumerable: true, configurable: true };
|
||||||
|
|
||||||
for (const hcValuePair of hcValuePairs) {
|
for (const hcValue of hcValues) {
|
||||||
for (const hcValue of hcValuePair) {
|
|
||||||
const resolvedOptions = new Intl.DateTimeFormat(`de-u-hc-${hcValue}`, {
|
const resolvedOptions = new Intl.DateTimeFormat(`de-u-hc-${hcValue}`, {
|
||||||
hour: 'numeric'
|
hour: 'numeric'
|
||||||
}).resolvedOptions();
|
}).resolvedOptions();
|
||||||
|
|
||||||
assert(hcValuePair.includes(resolvedOptions.hourCycle));
|
assert.sameValue(resolvedOptions.hourCycle, hcValue);
|
||||||
assert.sameValue(resolvedOptions.hour12, hour12Values.includes(hcValue));
|
assert.sameValue(resolvedOptions.hour12, hour12Values.includes(hcValue));
|
||||||
|
|
||||||
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
||||||
verifyProperty(resolvedOptions, 'hour12', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hour12', dataPropertyDesc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Values passed via options work */
|
/* Values passed via options work */
|
||||||
|
|
||||||
for (const hcValuePair of hcValuePairs) {
|
for (const hcValue of hcValues) {
|
||||||
for (const hcValue of hcValuePair) {
|
|
||||||
const resolvedOptions = new Intl.DateTimeFormat(`en-US`, {
|
const resolvedOptions = new Intl.DateTimeFormat(`en-US`, {
|
||||||
hour: 'numeric',
|
hour: 'numeric',
|
||||||
hourCycle: hcValue
|
hourCycle: hcValue
|
||||||
}).resolvedOptions();
|
}).resolvedOptions();
|
||||||
|
|
||||||
assert(hcValuePair.includes(resolvedOptions.hourCycle));
|
assert.sameValue(resolvedOptions.hourCycle, hcValue);
|
||||||
assert.sameValue(resolvedOptions.hour12, hour12Values.includes(hcValue));
|
assert.sameValue(resolvedOptions.hour12, hour12Values.includes(hcValue));
|
||||||
|
|
||||||
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
||||||
verifyProperty(resolvedOptions, 'hour12', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hour12', dataPropertyDesc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* When both extension key and option is passed, option takes precedence */
|
/* When both extension key and option is passed, option takes precedence */
|
||||||
|
|
||||||
@ -67,7 +53,7 @@ let resolvedOptions = new Intl.DateTimeFormat(`en-US-u-hc-h12`, {
|
|||||||
hourCycle: 'h23'
|
hourCycle: 'h23'
|
||||||
}).resolvedOptions();
|
}).resolvedOptions();
|
||||||
|
|
||||||
assert(['h23', 'h24'].includes(resolvedOptions.hourCycle));
|
assert.sameValue(resolvedOptions.hourCycle, 'h23');
|
||||||
assert.sameValue(resolvedOptions.hour12, false);
|
assert.sameValue(resolvedOptions.hour12, false);
|
||||||
|
|
||||||
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
||||||
@ -81,7 +67,7 @@ resolvedOptions = new Intl.DateTimeFormat(`fr`, {
|
|||||||
hourCycle: 'h23'
|
hourCycle: 'h23'
|
||||||
}).resolvedOptions();
|
}).resolvedOptions();
|
||||||
|
|
||||||
assert(['h11', 'h12'].includes(resolvedOptions.hourCycle));
|
assert(hour12Values.includes(resolvedOptions.hourCycle));
|
||||||
assert.sameValue(resolvedOptions.hour12, true);
|
assert.sameValue(resolvedOptions.hour12, true);
|
||||||
|
|
||||||
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
||||||
@ -94,7 +80,7 @@ resolvedOptions = new Intl.DateTimeFormat(`fr-u-hc-h24`, {
|
|||||||
hour12: true,
|
hour12: true,
|
||||||
}).resolvedOptions();
|
}).resolvedOptions();
|
||||||
|
|
||||||
assert(['h11', 'h12'].includes(resolvedOptions.hourCycle));
|
assert(hour12Values.includes(resolvedOptions.hourCycle));
|
||||||
assert.sameValue(resolvedOptions.hour12, true);
|
assert.sameValue(resolvedOptions.hour12, true);
|
||||||
|
|
||||||
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
verifyProperty(resolvedOptions, 'hourCycle', dataPropertyDesc);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user