summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/Segmenter/constructor/supportedLocalesOf/options-toobject.js
blob: db621a80c602e84381b3e0a26b2392e1bbdae55f (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
// |reftest| skip-if(!Intl.Segmenter) -- Intl.Segmenter is not enabled unconditionally
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.Segmenter.supportedLocalesOf
description: Checks handling of non-object options arguments to the supportedLocalesOf function.
info: |
    SupportedLocales ( availableLocales, requestedLocales, options )

    1. If options is not undefined, then
        a. Let options be ? ToObject(options).
features: [Intl.Segmenter]
---*/

assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function",
                 "Should support Intl.Segmenter.supportedLocalesOf.");

let called;
Object.defineProperties(Object.prototype, {
  "localeMatcher": {
    get() {
      ++called;
      return "best fit";
    }
  }
});

const optionsArguments = [
  true,
  "test",
  7,
  Symbol(),
];

for (const options of optionsArguments) {
  called = 0;
  const result = Intl.Segmenter.supportedLocalesOf([], options);
  assert.sameValue(Array.isArray(result), true, `Expected array from ${String(options)}`);
  assert.sameValue(called, 1, `Expected one call from ${String(options)}`);
}


reportCompare(0, 0);