Debian Codegraph @

js/src/tests/test262/intl402/RelativeTimeFormat/constructor/supportedLocalesOf/options-toobject.js

raw
1 // Copyright 2018 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-Intl.RelativeTimeFormat.supportedLocalesOf
6 description: Checks handling of non-object options arguments to the supportedLocalesOf function.
7 info: |
8 SupportedLocales ( availableLocales, requestedLocales, options )
9
10 1. If options is not undefined, then
11 a. Let options be ? ToObject(options).
12 features: [Intl.RelativeTimeFormat]
13 ---*/
14
15 assert.sameValue(typeof Intl.RelativeTimeFormat.supportedLocalesOf, "function",
16 "Should support Intl.RelativeTimeFormat.supportedLocalesOf.");
17
18 let called;
19 Object.defineProperties(Object.prototype, {
20 "localeMatcher": {
21 get() {
22 ++called;
23 return "best fit";
24 }
25 }
26 });
27
28 const optionsArguments = [
29 true,
30 "test",
31 7,
32 Symbol(),
33 ];
34
35 for (const options of optionsArguments) {
36 called = 0;
37 const result = Intl.RelativeTimeFormat.supportedLocalesOf([], options);
38 assert.sameValue(Array.isArray(result), true, `Expected array from ${String(options)}`);
39 assert.sameValue(called, 1, `Expected one call from ${String(options)}`);
40 }
41
42
43 reportCompare(0, 0);