tor-browser

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

calendars-accepted-by-DisplayNames.js (1621B)


      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 "calendar" values can be used with DisplayNames.
      8 info: |
      9  Intl.supportedValuesOf ( key )
     10 
     11  1. Let key be ? ToString(key).
     12  2. If key is "calendar", then
     13    a. Let list be ! AvailableCalendars( ).
     14  ...
     15  9. Return ! CreateArrayFromList( list ).
     16 
     17  AvailableCalendars ( )
     18    The AvailableCalendars abstract operation returns a List, ordered as if an
     19    Array of the same values had been sorted using %Array.prototype.sort% using
     20    undefined as comparefn, that contains unique calendar types identifying the
     21    calendars for which the implementation provides the functionality of
     22    Intl.DateTimeFormat objects. The list must include "gregory".
     23 includes: [testIntl.js]
     24 locale: [en]
     25 features: [Intl-enumeration, Intl.DisplayNames-v2, Array.prototype.includes]
     26 ---*/
     27 
     28 const calendars = Intl.supportedValuesOf("calendar");
     29 
     30 const obj = new Intl.DisplayNames("en", {type: "calendar", fallback: "none"});
     31 
     32 for (let calendar of calendars) {
     33  assert.sameValue(typeof obj.of(calendar), "string",
     34                   `${calendar} is supported by DisplayNames`);
     35 }
     36 
     37 for (let calendar of allCalendars()) {
     38  if (typeof obj.of(calendar) === "string") {
     39    assert(calendars.includes(calendar),
     40           `${calendar} supported but not returned by supportedValuesOf`);
     41  } else {
     42    assert(!calendars.includes(calendar),
     43           `${calendar} not supported but returned by supportedValuesOf`);
     44  }
     45 }
     46 
     47 reportCompare(0, 0);