summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Intl/supportedValuesOf/calendars-accepted-by-DateTimeFormat.js
blob: 9cbaa39c06259ab46a1de6ba2721f6fdf7087093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (C) 2021 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.supportedvaluesof
description: >
  The returned "calendar" values can be used with DateTimeFormat.
info: |
  Intl.supportedValuesOf ( key )

  1. Let key be ? ToString(key).
  2. If key is "calendar", then
    a. Let list be ! AvailableCalendars( ).
  ...
  9. Return ! CreateArrayFromList( list ).

  AvailableCalendars ( )
    The AvailableCalendars abstract operation returns a List, ordered as if an
    Array of the same values had been sorted using %Array.prototype.sort% using
    undefined as comparefn, that contains unique calendar types identifying the
    calendars for which the implementation provides the functionality of
    Intl.DateTimeFormat objects. The list must include "gregory".
includes: [testIntl.js]
locale: [en]
features: [Intl-enumeration, Array.prototype.includes]
---*/

const calendars = Intl.supportedValuesOf("calendar");

for (let calendar of calendars) {
  let obj = new Intl.DateTimeFormat("en", {calendar});
  assert.sameValue(obj.resolvedOptions().calendar, calendar,
                   `${calendar} is supported by DateTimeFormat`);
}

for (let calendar of allCalendars()) {
  let obj = new Intl.DateTimeFormat("en", {calendar});
  if (obj.resolvedOptions().calendar === calendar) {
    assert(calendars.includes(calendar),
           `${calendar} supported but not returned by supportedValuesOf`);
  } else {
    assert(!calendars.includes(calendar),
           `${calendar} not supported but returned by supportedValuesOf`);
  }
}

reportCompare(0, 0);