tor-browser

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

currencies-accepted-by-NumberFormat.js (1815B)


      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 "currency" values can be used with NumberFormat.
      8 info: |
      9  Intl.supportedValuesOf ( key )
     10 
     11  1. Let key be ? ToString(key).
     12  ...
     13  4. Else if key is "currency", then
     14    a. Let list be ! AvailableCurrencies( ).
     15  ...
     16  9. Return ! CreateArrayFromList( list ).
     17 
     18  AvailableCurrencies ( )
     19    The AvailableCurrencies abstract operation returns a List, ordered as if an
     20    Array of the same values had been sorted using %Array.prototype.sort% using
     21    undefined as comparefn, that contains unique, well-formed, and upper case
     22    canonicalized 3-letter ISO 4217 currency codes, identifying the currencies
     23    for which the implementation provides the functionality of Intl.DisplayNames
     24    and Intl.NumberFormat objects.
     25 locale: [en]
     26 features: [Intl-enumeration]
     27 ---*/
     28 
     29 const currencies = Intl.supportedValuesOf("currency");
     30 
     31 for (let currency of currencies) {
     32  let obj = new Intl.NumberFormat("en", {style: "currency", currency});
     33  assert.sameValue(obj.resolvedOptions().currency, currency,
     34                   `${currency} is supported by NumberFormat`);
     35 }
     36 
     37 // Note: We can't test that additional currency values not present in |currencies|
     38 // aren't supported by Intl.NumberFormat, because PartitionNumberPattern defaults
     39 // to using the currency code itself when the currency is unsupported:
     40 //
     41 // PartitionNumberPattern, step 8.k.iii:
     42 // Let cd be an ILD String value representing currency after x in currencyDisplay form,
     43 // which may depend on x in languages having different plural forms. If the
     44 // implementation does not have such a representation of currency, use currency itself.
     45 
     46 reportCompare(0, 0);