tor-browser

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

notation.js (1391B)


      1 // Copyright 2025 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-initializepluralrules
      6 description: Checks that the notation option is picked up correctly.
      7 info: |
      8  Intl.PluralRules ( [ _locales_ [ , _options_ ] ] )
      9    ...
     10    1. Let notation be ? GetOption(options, "notation", "string", « "standard", "compact", "scientific", "engineering" », "standard").
     11    ...
     12 ---*/
     13 
     14 const validValues = ["standard", "compact", "scientific", "engineering"];
     15 const invalidValues = ["COMPACT", "ståndard", 123, false, null, {}, [], ""];
     16 
     17 for (const value of validValues) {
     18  const pr = new Intl.PluralRules("en", { notation: value });
     19  assert(pr.resolvedOptions().notation === value, `Resolved options should have notation ${value}`);
     20 }
     21 
     22 // Also test with String wrappers.
     23 for (const value of validValues) {
     24  const pr = new Intl.PluralRules("en", { notation: new String(value) });
     25  assert(pr.resolvedOptions().notation === value, `Resolved options should have notation ${value}`);
     26 }
     27 
     28 for (const value of invalidValues) {
     29  assert.throws(RangeError, () => {
     30    new Intl.PluralRules("en", { notation: value });
     31  }, `Exception should be thrown for ${value}`);
     32 }
     33 
     34 assert.throws(TypeError, () => {
     35  new Intl.PluralRules("en", { notation: Symbol("foo") });
     36 }, `Exception should be thrown for symbol`);
     37 
     38 reportCompare(0, 0);