tor-browser

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

numberingSystems-accepted-by-NumberFormat.js (1961B)


      1 // Copyright (C) 2021 André Bargull. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 esid: sec-intl.supportedvaluesof
      6 description: >
      7  The returned "numberingSystem" values can be used with NumberFormat.
      8 info: |
      9  Intl.supportedValuesOf ( key )
     10 
     11  1. Let key be ? ToString(key).
     12  ...
     13  5. Else if key is "numberingSystem", then
     14    a. Let list be ! AvailableNumberingSystems( ).
     15  ...
     16  9. Return ! CreateArrayFromList( list ).
     17 
     18  AvailableNumberingSystems ( )
     19    The AvailableNumberingSystems abstract operation returns a List, ordered as
     20    if an Array of the same values had been sorted using %Array.prototype.sort%
     21    using undefined as comparefn, that contains unique numbering systems
     22    identifiers identifying the numbering systems for which the implementation
     23    provides the functionality of Intl.DateTimeFormat, Intl.NumberFormat, and
     24    Intl.RelativeTimeFormat objects. The list must include the Numbering System
     25    value of every row of Table 4, except the header row.
     26 includes: [testIntl.js]
     27 locale: [en]
     28 features: [Intl-enumeration, Array.prototype.includes]
     29 ---*/
     30 
     31 const numberingSystems = Intl.supportedValuesOf("numberingSystem");
     32 
     33 for (let numberingSystem of numberingSystems) {
     34  let obj = new Intl.NumberFormat("en", {numberingSystem});
     35  assert.sameValue(obj.resolvedOptions().numberingSystem, numberingSystem,
     36                   `${numberingSystem} is supported by NumberFormat`);
     37 }
     38 
     39 for (let numberingSystem of allNumberingSystems()) {
     40  let obj = new Intl.NumberFormat("en", {numberingSystem});
     41  if (obj.resolvedOptions().numberingSystem === numberingSystem) {
     42    assert(numberingSystems.includes(numberingSystem),
     43           `${numberingSystem} supported but not returned by supportedValuesOf`);
     44  } else {
     45    assert(!numberingSystems.includes(numberingSystem),
     46           `${numberingSystem} not supported but returned by supportedValuesOf`);
     47  }
     48 }
     49 
     50 reportCompare(0, 0);