From c324e5c6205a7e480e4f916ac49a521bde905141 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Wed, 1 Sep 2021 12:54:49 -0400 Subject: [PATCH] Correct tests for Unicode Language Identifier The underscore character "_" is only accepted for the sep production [1] when the backwards-compatibility extensions [2] are enabled. However, ECMA-402 only accepts Unicode BCP 47 locale identifiers [3], meaning identifiers *without* the backwards-compatibility extensions. [1] https://unicode.org/reports/tr35/#Unicode_language_identifier [2] https://unicode.org/reports/tr35/#BCP_47_Conformance [3] https://tc39.es/ecma402/#sec-language-tags --- .../prototype/of/type-calendar-invalid.js | 16 ++++++++++++++++ .../prototype/of/type-calendar-valid.js | 5 ----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/test/intl402/DisplayNames/prototype/of/type-calendar-invalid.js b/test/intl402/DisplayNames/prototype/of/type-calendar-invalid.js index 3ca56c39a5..b9f310adb9 100644 --- a/test/intl402/DisplayNames/prototype/of/type-calendar-invalid.js +++ b/test/intl402/DisplayNames/prototype/of/type-calendar-invalid.js @@ -43,3 +43,19 @@ assert.throws(RangeError, function() { assert.throws(RangeError, function() { displayNames.of('abc def'); }, 'interstitial space'); + +assert.throws(RangeError, function() { + displayNames.of('123_abc'); +}, '2 segments, minimum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('12345678_abcdefgh'); +}, '2 segments, maximum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('123_abc_ABC'); +}, '3 segments, minimum length, underscore'); + +assert.throws(RangeError, function() { + displayNames.of('12345678_abcdefgh_ABCDEFGH'); +}, '3 segments, maximum length, underscore'); diff --git a/test/intl402/DisplayNames/prototype/of/type-calendar-valid.js b/test/intl402/DisplayNames/prototype/of/type-calendar-valid.js index 7b6913fa90..4d7b0c49ce 100644 --- a/test/intl402/DisplayNames/prototype/of/type-calendar-valid.js +++ b/test/intl402/DisplayNames/prototype/of/type-calendar-valid.js @@ -25,8 +25,3 @@ assert.sameValue(typeof displayNames.of('123-abc'), 'string', '2 segments, minim assert.sameValue(typeof displayNames.of('12345678-abcdefgh'), 'string', '2 segments, maximum length, dash'); assert.sameValue(typeof displayNames.of('123-abc-ABC'), 'string', '3 segments, minimum length, dash'); assert.sameValue(typeof displayNames.of('12345678-abcdefgh-ABCDEFGH'), 'string', '3 segments, maximum length, dash'); - -assert.sameValue(typeof displayNames.of('123_abc'), 'string', '2 segments, minimum length, underscore'); -assert.sameValue(typeof displayNames.of('12345678_abcdefgh'), 'string', '2 segments, maximum length, underscore'); -assert.sameValue(typeof displayNames.of('123_abc_ABC'), 'string', '3 segments, minimum length, underscore'); -assert.sameValue(typeof displayNames.of('12345678_abcdefgh_ABCDEFGH'), 'string', '3 segments, maximum length, underscore');