test262/test/intl402/Intl/supportedValuesOf/coerced-to-string.js
André Bargull 66a3c3aa8b Add tests for Intl Enumeration API
Covers the usual surface tests and additional functionality tests which were
upstreamed from existing tests in SpiderMonkey.

Fixes #3131
2021-09-08 09:29:06 -04:00

37 lines
929 B
JavaScript

// 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: >
Input key is coerced with ToString.
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 ).
includes: [compareArray.js]
features: [Intl-enumeration]
---*/
const calendars = Intl.supportedValuesOf("calendar");
// ToString on a String object.
assert.compareArray(Intl.supportedValuesOf(new String("calendar")), calendars);
// ToString on a plain object.
let obj = {
toString() {
return "calendar";
}
};
assert.compareArray(Intl.supportedValuesOf(obj), calendars);
// ToString() of a symbol throws a TypeError.
assert.throws(TypeError, function() {
Intl.supportedValuesOf(Symbol());
});