options-localeMatcher-abrupt-throws.js (1168B)
1 // Copyright (C) 2019 Leo Balter. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 esid: sec-Intl.DisplayNames 6 description: > 7 Return abrupt completion from GetOption localeMatcher 8 info: | 9 Intl.DisplayNames ([ locales [ , options ]]) 10 11 1. If NewTarget is undefined, throw a TypeError exception. 12 2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%", 13 « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »). 14 ... 15 4. If options is undefined, then 16 a. Let options be ObjectCreate(null). 17 5. Else 18 a. Let options be ? ToObject(options). 19 ... 20 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit"). 21 22 GetOption ( options, property, type, values, fallback ) 23 24 1. Let value be ? Get(options, property). 25 ... 26 features: [Intl.DisplayNames] 27 locale: [en] 28 ---*/ 29 30 var options = {}; 31 Object.defineProperty(options, 'localeMatcher', { 32 get() { throw new Test262Error(); }, 33 }); 34 35 assert.throws(Test262Error, () => { 36 new Intl.DisplayNames('en', options); 37 }); 38 39 reportCompare(0, 0);