constructor-options-numberingsystem-invalid.js (1093B)
1 // Copyright 2018 André Bargull; Igalia, S.L. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-intl.locale 6 description: > 7 Checks error cases for the options argument to the Locale constructor. 8 info: | 9 Intl.Locale( tag [, options] ) 10 11 ... 12 28. If numberingSystem is not undefined, then 13 a. If numberingSystem does not match the [(3*8alphanum) *("-" (3*8alphanum))] sequence, throw a RangeError exception. 14 15 features: [Intl.Locale] 16 ---*/ 17 18 19 /* 20 alphanum = (ALPHA / DIGIT) ; letters and numbers 21 numberingSystem = (3*8alphanum) *("-" (3*8alphanum)) 22 */ 23 const invalidNumberingSystemOptions = [ 24 "", 25 "a", 26 "ab", 27 "abcdefghi", 28 "abc-abcdefghi", 29 "!invalid!", 30 "-latn-", 31 "latn-", 32 "latn--", 33 "latn-ca", 34 "latn-ca-", 35 "latn-ca-gregory", 36 ]; 37 for (const numberingSystem of invalidNumberingSystemOptions) { 38 assert.throws(RangeError, function() { 39 new Intl.Locale('en', {numberingSystem}); 40 }, `new Intl.Locale("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`); 41 } 42 43 reportCompare(0, 0);