diff --git a/test/intl402/DateTimeFormat/constructor-options-calendar-invalid.js b/test/intl402/DateTimeFormat/constructor-options-calendar-invalid.js new file mode 100644 index 0000000000..b5073eec92 --- /dev/null +++ b/test/intl402/DateTimeFormat/constructor-options-calendar-invalid.js @@ -0,0 +1,40 @@ +// Copyright 2020 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: > + Checks error cases for the options argument to the DateTimeFormat constructor. +info: | + InitializeDateTimeFormat ( dateTimeFormat, locales, options ) + + ... + 7. If calendar is not undefined, then + a. If calendar does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. +---*/ + +/* + alphanum = (ALPHA / DIGIT) ; letters and numbers + numberingSystem = (3*8alphanum) *("-" (3*8alphanum)) +*/ +const invalidCalendarOptions = [ + "", + "a", + "ab", + "abcdefghi", + "abc-abcdefghi", + "!invalid!", + "-gregory-", + "gregory-", + "gregory--", + "gregory-nu", + "gregory-nu-", + "gregory-nu-latn", + "gregoryé", + "gregory역법", +]; +for (const calendar of invalidCalendarOptions) { + assert.throws(RangeError, function() { + new Intl.DateTimeFormat('en', {calendar}); + }, `new Intl.DateTimeFormat("en", {calendar: "${calendar}"}) throws RangeError`); +} diff --git a/test/intl402/DateTimeFormat/constructor-options-numberingSystem-invalid.js b/test/intl402/DateTimeFormat/constructor-options-numberingSystem-invalid.js new file mode 100644 index 0000000000..b0c5b51fcb --- /dev/null +++ b/test/intl402/DateTimeFormat/constructor-options-numberingSystem-invalid.js @@ -0,0 +1,40 @@ +// Copyright 2020 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializedatetimeformat +description: > + Checks error cases for the options argument to the DateTimeFormat constructor. +info: | + InitializeDateTimeFormat ( dateTimeFormat, locales, options ) + + ... + 10. If numberingSystem is not undefined, then + a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. +---*/ + +/* + alphanum = (ALPHA / DIGIT) ; letters and numbers + numberingSystem = (3*8alphanum) *("-" (3*8alphanum)) +*/ +const invalidNumberingSystemOptions = [ + "", + "a", + "ab", + "abcdefghi", + "abc-abcdefghi", + "!invalid!", + "-latn-", + "latn-", + "latn--", + "latn-ca", + "latn-ca-", + "latn-ca-gregory", + "latné", + "latn编号", +]; +for (const numberingSystem of invalidNumberingSystemOptions) { + assert.throws(RangeError, function() { + new Intl.DateTimeFormat('en', {numberingSystem}); + }, `new Intl.DateTimeFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`); +} diff --git a/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js b/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js deleted file mode 100644 index 78d2e5f93c..0000000000 --- a/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2020 Google Inc, Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-initializedatetimeformat -description: > - Tests that invalid numberingSystem and calendar option throws RangeError. -author: Caio Lima ----*/ - -let invalidValues = ["ab", "aaaaaaaabbbbbababa."]; - -var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; - -invalidValues.forEach(function (value) { - assert.throws(RangeError, function () { - return new Intl.DateTimeFormat([defaultLocale], {numberingSystem: value}); - }, "Invalid numberingSystem value " + value + " was not rejected."); - assert.throws(RangeError, function () { - return new Intl.DateTimeFormat([defaultLocale + "-u-nu-" + value]); - }, "Invalid numberingSystem value " + value + " was not rejected."); - - assert.throws(RangeError, function () { - return new Intl.DateTimeFormat([defaultLocale], {calendar: value}); - }, "Invalid calendar value " + value + " was not rejected."); - assert.throws(RangeError, function () { - return new Intl.DateTimeFormat([defaultLocale + "-u-ca-" + value]); - }, "Invalid calendar value " + value + " was not rejected."); -}); - diff --git a/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js b/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js new file mode 100644 index 0000000000..bb9167e5bb --- /dev/null +++ b/test/intl402/NumberFormat/constructor-options-numberingSystem-invalid.js @@ -0,0 +1,40 @@ +// Copyright 2020 André Bargull; Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-initializenumberformat +description: > + Checks error cases for the options argument to the NumberFormat constructor. +info: | + InitializeNumberFormat ( numberFormat, locales, options ) + + ... + 8. If numberingSystem is not undefined, then + a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception. +---*/ + +/* + alphanum = (ALPHA / DIGIT) ; letters and numbers + numberingSystem = (3*8alphanum) *("-" (3*8alphanum)) +*/ +const invalidNumberingSystemOptions = [ + "", + "a", + "ab", + "abcdefghi", + "abc-abcdefghi", + "!invalid!", + "-latn-", + "latn-", + "latn--", + "latn-ca", + "latn-ca-", + "latn-ca-gregory", + "latné", + "latn编号", +]; +for (const numberingSystem of invalidNumberingSystemOptions) { + assert.throws(RangeError, function() { + new Intl.NumberFormat('en', {numberingSystem}); + }, `new Intl.NumberFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`); +} diff --git a/test/intl402/NumberFormat/invalid-numbering-system-options.js b/test/intl402/NumberFormat/invalid-numbering-system-options.js deleted file mode 100644 index 4ae3fcef9d..0000000000 --- a/test/intl402/NumberFormat/invalid-numbering-system-options.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2020 Google Inc, Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-initializenumberformat -description: > - Tests that invalid numberingSystem option throws RangeError. -author: Caio Lima ----*/ - -let invalidValues = ["ab", "aaaaaaaabbbbbababa."]; - -var defaultLocale = new Intl.NumberFormat().resolvedOptions().locale; - -invalidValues.forEach(function (value) { - assert.throws(RangeError, function () { - return new Intl.NumberFormat([defaultLocale], {numberingSystem: value}); - }, "Invalid numberingSystem value " + value + " was not rejected."); - assert.throws(RangeError, function () { - return new Intl.NumberFormat([defaultLocale + "-u-nu-" + value]); - }, "Invalid numberingSystem value " + value + " was not rejected."); -}); diff --git a/test/intl402/RelativeTimeFormat/constructor/constructor/options-numberingSystem-invalid.js b/test/intl402/RelativeTimeFormat/constructor/constructor/options-numberingSystem-invalid.js index 20dac6674d..6adbcfaa6a 100644 --- a/test/intl402/RelativeTimeFormat/constructor/constructor/options-numberingSystem-invalid.js +++ b/test/intl402/RelativeTimeFormat/constructor/constructor/options-numberingSystem-invalid.js @@ -10,7 +10,7 @@ info: | ... 8. If numberingSystem is not undefined, then - a. If numberingSystem does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception. + a. If numberingSystem does not match the type sequence (from UTS 35 Unicode Locale Identifier, section 3.2), throw a RangeError exception. features: [Intl.RelativeTimeFormat] ---*/ @@ -34,6 +34,8 @@ const invalidNumberingSystemOptions = [ "latn-ca", "latn-ca-", "latn-ca-gregory", + "latné", + "latn编号", ]; for (const numberingSystem of invalidNumberingSystemOptions) { assert.throws(RangeError, function() {