Added tests with invalid values for calendar and numberingSystem (#2480)

This commit is contained in:
Caio Lima 2020-01-24 16:21:33 -03:00 committed by Leo Balter
parent 4383f2c6ba
commit 04b1d2254b
2 changed files with 52 additions and 0 deletions

View File

@ -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.");
});

View File

@ -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.");
});