Debian Codegraph @

js/src/tests/test262/intl402/DisplayNames/options-languagedisplay-valid.js

raw
1 // Copyright (C) 2021 the V8 project authors. 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: Valid options for languageDisplay
7 info: |
8 Intl.DisplayNames ( locales , options )
9
10 1. If NewTarget is undefined, throw a TypeError exception.
11 2. Let displayNames be ? OrdinaryCreateFromConstructor(NewTarget, "%DisplayNamesPrototype%",
12 « [[InitializedDisplayNames]], [[Locale]], [[Style]], [[Type]], [[Fallback]], [[Fields]] »).
13 ...
14 4. Let options be ? ToObject(options).
15 ...
16 8. Let matcher be ? GetOption(options, "localeMatcher", "string", « "lookup", "best fit" », "best fit").
17 ...
18 10. Let style be ? GetOption(options, "style", "string", « "narrow", "short", "long" », "long").
19 ...
20 12. Let type be ? GetOption(options, "type", "string", « "language", "region", "script", "currency" », undefined).
21 13. If type is undefined, throw a TypeError exception.
22 ...
23 24. Let languageDisplay be ? GetOption(options, "languageDisplay", "string", « "dialect", "standard" », "dialect").
24 ...
25
26 GetOption ( options, property, type, values, fallback )
27
28 1. Let value be ? Get(options, property).
29 ...
30 features: [Intl.DisplayNames-v2]
31 locale: [en]
32 ---*/
33
34 // results for option values verified in the tests for resolvedOptions
35
36 const languageDisplays = [
37 undefined,
38 'dialect',
39 'standard'
40 ];
41
42 languageDisplays.forEach(languageDisplay => {
43 const obj = new Intl.DisplayNames('en', { languageDisplay, type: 'language'});
44
45 assert(obj instanceof Intl.DisplayNames, `instanceof check - ${languageDisplay}`);
46 assert.sameValue(Object.getPrototypeOf(obj), Intl.DisplayNames.prototype, `proto check - ${languageDisplay}`);
47 });
48
49 reportCompare(0, 0);