tor-browser

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

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


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