options-toobject.js (1138B)
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.Segmenter.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.Segmenter] 13 ---*/ 14 15 assert.sameValue(typeof Intl.Segmenter.supportedLocalesOf, "function", 16 "Should support Intl.Segmenter.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.Segmenter.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);