Improve coverage for Intl Locale Info proposal

This commit is contained in:
Mike Pennisi 2021-07-20 18:42:28 -04:00 committed by Rick Waldron
parent d19534c3ce
commit 347b651e95
7 changed files with 30 additions and 0 deletions

View File

@ -13,3 +13,4 @@ features: [Intl.Locale,Intl.Locale-info]
---*/
assert(Array.isArray(new Intl.Locale('en').calendars));
assert(new Intl.Locale('en').calendars.length > 0, 'array has at least one element');

View File

@ -18,6 +18,7 @@ features: [Intl.Locale,Intl.Locale-info]
---*/
const output = new Intl.Locale('en').collations;
assert(output.length > 0, 'array has at least one element');
output.forEach(c => {
if(['standard', 'search'].includes(c))
throw new Test262Error();

View File

@ -17,6 +17,7 @@ features: [Intl.Locale,Intl.Locale-info]
---*/
const output = new Intl.Locale('en').hourCycles;
assert(output.length > 0, 'array has at least one element');
output.forEach(hc => {
if(!['h11', 'h12', 'h23', 'h24'].includes(hc))
throw new Test262Error();

View File

@ -13,3 +13,4 @@ features: [Intl.Locale,Intl.Locale-info]
---*/
assert(Array.isArray(new Intl.Locale('en').numberingSystems));
assert(new Intl.Locale('en').numberingSystems.length > 0, 'array has at least one element');

View File

@ -23,3 +23,9 @@ verifyProperty(result, 'direction', {
enumerable: true,
configurable: true
});
const direction = new Intl.Locale('en').textInfo.direction;
assert(
direction === 'rtl' || direction === 'ltr',
'value of the `direction` property'
);

View File

@ -14,3 +14,4 @@ features: [Intl.Locale,Intl.Locale-info]
---*/
assert(Array.isArray(new Intl.Locale('en-US').timeZones));
assert(new Intl.Locale('en-US').timeZones.length > 0, 'array has at least one element');

View File

@ -24,6 +24,9 @@ includes: [propertyHelper.js, compareArray.js]
---*/
const result = new Intl.Locale('en').weekInfo;
function isIntegerBetweenOneAndSeven(value) {
return value === 1 || value === 2 || value === 3 || value === 4 || value === 5 || value === 6 || value === 7;
}
assert.compareArray(Reflect.ownKeys(result), ['firstDay', 'weekendStart', 'weekendEnd', 'minimalDays']);
@ -32,21 +35,37 @@ verifyProperty(result, 'firstDay', {
enumerable: true,
configurable: true
});
assert(
isIntegerBetweenOneAndSeven(new Intl.Locale('en').weekInfo.firstDay),
'`firstDay` must be an integer between one and seven (inclusive)'
);
verifyProperty(result, 'weekendStart', {
writable: true,
enumerable: true,
configurable: true
});
assert(
isIntegerBetweenOneAndSeven(new Intl.Locale('en').weekInfo.weekendStart),
'`weekendStart` must be an integer between one and seven (inclusive)'
);
verifyProperty(result, 'weekendEnd', {
writable: true,
enumerable: true,
configurable: true
});
assert(
isIntegerBetweenOneAndSeven(new Intl.Locale('en').weekInfo.weekendEnd),
'`weekendEnd` must be an integer between one and seven (inclusive)'
);
verifyProperty(result, 'minimalDays', {
writable: true,
enumerable: true,
configurable: true
});
assert(
isIntegerBetweenOneAndSeven(new Intl.Locale('en').weekInfo.minimalDays),
'`minimalDays` must be an integer between one and seven (inclusive)'
);