From 347b651e950cdfb74ae8b7172c40aa295f5859a3 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Tue, 20 Jul 2021 18:42:28 -0400 Subject: [PATCH] Improve coverage for Intl Locale Info proposal --- .../prototype/calendars/output-array.js | 1 + .../collations/output-array-values.js | 1 + .../hourCycles/output-array-values.js | 1 + .../numberingSystems/output-array.js | 1 + .../prototype/textInfo/output-object-keys.js | 6 ++++++ .../prototype/timeZones/output-array.js | 1 + .../prototype/weekInfo/output-object-keys.js | 19 +++++++++++++++++++ 7 files changed, 30 insertions(+) diff --git a/test/intl402/Locale/prototype/calendars/output-array.js b/test/intl402/Locale/prototype/calendars/output-array.js index be4a54b525..4f7585c4fe 100644 --- a/test/intl402/Locale/prototype/calendars/output-array.js +++ b/test/intl402/Locale/prototype/calendars/output-array.js @@ -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'); diff --git a/test/intl402/Locale/prototype/collations/output-array-values.js b/test/intl402/Locale/prototype/collations/output-array-values.js index 152e9985ec..04dce3ea5c 100644 --- a/test/intl402/Locale/prototype/collations/output-array-values.js +++ b/test/intl402/Locale/prototype/collations/output-array-values.js @@ -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(); diff --git a/test/intl402/Locale/prototype/hourCycles/output-array-values.js b/test/intl402/Locale/prototype/hourCycles/output-array-values.js index 231c1629f1..37cfe713ec 100644 --- a/test/intl402/Locale/prototype/hourCycles/output-array-values.js +++ b/test/intl402/Locale/prototype/hourCycles/output-array-values.js @@ -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(); diff --git a/test/intl402/Locale/prototype/numberingSystems/output-array.js b/test/intl402/Locale/prototype/numberingSystems/output-array.js index a48ab92fc6..d26e2b4737 100644 --- a/test/intl402/Locale/prototype/numberingSystems/output-array.js +++ b/test/intl402/Locale/prototype/numberingSystems/output-array.js @@ -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'); diff --git a/test/intl402/Locale/prototype/textInfo/output-object-keys.js b/test/intl402/Locale/prototype/textInfo/output-object-keys.js index 5e5626f768..38b2d9bc8b 100644 --- a/test/intl402/Locale/prototype/textInfo/output-object-keys.js +++ b/test/intl402/Locale/prototype/textInfo/output-object-keys.js @@ -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' +); diff --git a/test/intl402/Locale/prototype/timeZones/output-array.js b/test/intl402/Locale/prototype/timeZones/output-array.js index 7ea8e89b64..41ef4d527b 100644 --- a/test/intl402/Locale/prototype/timeZones/output-array.js +++ b/test/intl402/Locale/prototype/timeZones/output-array.js @@ -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'); diff --git a/test/intl402/Locale/prototype/weekInfo/output-object-keys.js b/test/intl402/Locale/prototype/weekInfo/output-object-keys.js index ed7a2a51ca..bb536c6569 100644 --- a/test/intl402/Locale/prototype/weekInfo/output-object-keys.js +++ b/test/intl402/Locale/prototype/weekInfo/output-object-keys.js @@ -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)' +);