Debian Codegraph @

js/src/tests/test262/intl402/DisplayNames/options-fallback-abrupt-throws.js

raw
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 fallback
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. Let options be ? ToObject(options).
16 ...
17 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
18 13. If type is undefined, throw a TypeError exception.
19 ...
20 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
21 ...
22
23 GetOption ( options, property, type, values, fallback )
24
25 1. Let value be ? Get(options, property).
26 ...
27 features: [Intl.DisplayNames]
28 locale: [en]
29 ---*/
30
31 var options = { type: 'language' };
32 Object.defineProperty(options, 'fallback', {
33 get() { throw new Test262Error(); },
34 });
35
36 assert.throws(Test262Error, () => {
37 new Intl.DisplayNames('en', options);
38 });
39
40 reportCompare(0, 0);