Debian Codegraph @

js/src/tests/test262/intl402/DisplayNames/locales-length-poison-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 Get Locales length
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 3. Let requestedLocales be ? CanonicalizeLocaleList(locales).
15 ...
16
17 CanonicalizeLocaleList ( locales )
18
19 1. If locales is undefined, then
20 a. Return a new empty List.
21 2. Let seen be a new empty List.
22 3. If Type(locales) is String, then
23 a. Let O be CreateArrayFromList(« locales »).
24 4. Else,
25 a. Let O be ? ToObject(locales).
26 5. Let len be ? ToLength(? Get(O, "length")).
27 features: [Intl.DisplayNames]
28 ---*/
29
30 var locales = {};
31
32 Object.defineProperty(locales, 'length', {
33 get() {
34 throw new Test262Error();
35 }
36 });
37
38 assert.throws(Test262Error, () => {
39 new Intl.DisplayNames(locales);
40 });
41
42 reportCompare(0, 0);