tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

constructor-options-numberingSystem-invalid.js (1171B)


      1 // Copyright 2020 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-createdatetimeformat
      6 description: >
      7    Checks error cases for the options argument to the DateTimeFormat constructor.
      8 info: |
      9    CreateDateTimeFormat ( dateTimeFormat, locales, options, required, defaults )
     10    ...
     11    27. If numberingSystem is not undefined, then
     12        a. If numberingSystem does not match the Unicode Locale Identifier type nonterminal, throw a RangeError exception.
     13 ---*/
     14 
     15 /*
     16 alphanum = (ALPHA / DIGIT)     ; letters and numbers
     17 numberingSystem = (3*8alphanum) *("-" (3*8alphanum))
     18 */
     19 const invalidNumberingSystemOptions = [
     20  "",
     21  "a",
     22  "ab",
     23  "abcdefghi",
     24  "abc-abcdefghi",
     25  "!invalid!",
     26  "-latn-",
     27  "latn-",
     28  "latn--",
     29  "latn-ca",
     30  "latn-ca-",
     31  "latn-ca-gregory",
     32  "latné",
     33  "latn编号",
     34 ];
     35 for (const numberingSystem of invalidNumberingSystemOptions) {
     36  assert.throws(RangeError, function() {
     37    new Intl.DateTimeFormat('en', {numberingSystem});
     38  }, `new Intl.DateTimeFormat("en", {numberingSystem: "${numberingSystem}"}) throws RangeError`);
     39 }
     40 
     41 reportCompare(0, 0);