Debian Codegraph @

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

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