From 04b1d2254bbd787593a5a65f9db7f7ac656de105 Mon Sep 17 00:00:00 2001 From: Caio Lima Date: Fri, 24 Jan 2020 16:21:33 -0300 Subject: [PATCH] Added tests with invalid values for calendar and numberingSystem (#2480) --- ...valid-numbering-system-calendar-options.js | 30 +++++++++++++++++++ .../invalid-numbering-system-options.js | 22 ++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js create mode 100644 test/intl402/NumberFormat/invalid-numbering-system-options.js diff --git a/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js b/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js new file mode 100644 index 0000000000..78d2e5f93c --- /dev/null +++ b/test/intl402/DateTimeFormat/invalid-numbering-system-calendar-options.js @@ -0,0 +1,30 @@ +// 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/invalid-numbering-system-options.js b/test/intl402/NumberFormat/invalid-numbering-system-options.js new file mode 100644 index 0000000000..4ae3fcef9d --- /dev/null +++ b/test/intl402/NumberFormat/invalid-numbering-system-options.js @@ -0,0 +1,22 @@ +// 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."); +});