Debian Codegraph @

js/src/tests/test262/intl402/DisplayNames/options-fallback-valid.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 Valid options for 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 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
18 ...
19 10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
20 ...
21 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
22 13. If type is undefined, throw a TypeError exception.
23 ...
24 15. Let fallback be ? GetOption(options, "fallback", "string", « "code", "none" », "code").
25 ...
26
27 GetOption ( options, property, type, values, fallback )
28
29 1. Let value be ? Get(options, property).
30 ...
31 features: [Intl.DisplayNames]
32 locale: [en]
33 ---*/
34
35 // results for option values verified in the tests for resolvedOptions
36
37 const fallbacks = [
38 undefined,
39 'code',
40 'none'
41 ];
42
43 fallbacks.forEach(fallback => {
44 const obj = new Intl.DisplayNames('en', { fallback, type: 'language'});
45
46 assert(obj instanceof Intl.DisplayNames, `instanceof check - ${fallback}`);
47 assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${fallback}`);
48 });
49
50 reportCompare(0, 0);