| 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 DateTimeFormat. |
| 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, Array.prototype.includes] |
| 26 |
---*/ |
| 27 |
|
| 28 |
const calendars = Intl.supportedValuesOf("calendar"); |
| 29 |
|
| 30 |
for (let calendar of calendars) { |
| 31 |
let obj = new Intl.DateTimeFormat("en", {calendar}); |
| 32 |
assert.sameValue(obj.resolvedOptions().calendar, calendar, |
| 33 |
`${calendar} is supported by DateTimeFormat`); |
| 34 |
} |
| 35 |
|
| 36 |
for (let calendar of allCalendars()) { |
| 37 |
let obj = new Intl.DateTimeFormat("en", {calendar}); |
| 38 |
if (obj.resolvedOptions().calendar === calendar) { |
| 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); |