tor-browser

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

constructor-notation.js (973B)


      1 // Copyright 2019 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: Checks handling of the notation option to the NumberFormat constructor.
      7 info: |
      8    InitializeNumberFormat ( numberFormat, locales, options )
      9 
     10    16. Let notation be ? GetOption(options, "notation", "string", « "standard", "scientific", "engineering", "compact" », "standard").
     11    17. Set numberFormat.[[Notation]] to notation.
     12 
     13 features: [Intl.NumberFormat-unified]
     14 ---*/
     15 
     16 const values = [
     17  [undefined, "standard"],
     18  ["standard"],
     19  ["scientific"],
     20  ["engineering"],
     21  ["compact"],
     22 ];
     23 
     24 for (const [value, expected = value] of values) {
     25  const nf = new Intl.NumberFormat([], {
     26    notation: value,
     27  });
     28  const resolvedOptions = nf.resolvedOptions();
     29  assert.sameValue("notation" in resolvedOptions, true);
     30  assert.sameValue(resolvedOptions.notation, expected);
     31 }
     32 
     33 reportCompare(0, 0);