2019-11-18 18:55:57 +00:00
|
|
|
// Copyright 2019 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
// DisplayNames constructor can't be called as function.
|
|
|
|
assertThrows(() => Intl.DisplayNames('sr'), TypeError);
|
2020-07-14 08:06:23 +00:00
|
|
|
assertThrows(() => Intl.DisplayNames('sr', {}), TypeError);
|
|
|
|
assertThrows(() => Intl.DisplayNames(undefined, {}), TypeError);
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames('sr', {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames([], {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames(['fr', 'ar'], {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames({0: 'ja', 1:'fr'}, {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames({1: 'ja', 2:'fr'}, {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames('sr', {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
2020-07-14 08:06:23 +00:00
|
|
|
assertDoesNotThrow(() =>
|
|
|
|
new Intl.DisplayNames(undefined, {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {
|
|
|
|
localeMatcher: 'lookup',
|
|
|
|
style: 'short',
|
|
|
|
type: 'language',
|
|
|
|
fallback: 'code',
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {localeMatcher: 'lookup', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {localeMatcher: 'best fit', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {localeMatcher: 'hello', type: 'language'}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {localeMatcher: 'look up', type: 'language'}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {localeMatcher: 'bestfit', type: 'language'}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {style: 'long', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {style: 'short', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {style: 'narrow', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {style: 'giant', type: 'language'}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {fallback: 'code', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {fallback: 'none', type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {fallback: 'never', type: 'language'}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {type: 'language'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {type: 'region'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {type: 'script'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertDoesNotThrow(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {type: 'currency'}));
|
2019-11-18 18:55:57 +00:00
|
|
|
|
|
|
|
assertThrows(
|
2020-07-14 08:06:23 +00:00
|
|
|
() => new Intl.DisplayNames(
|
|
|
|
'sr', {type: ''}),
|
2019-11-18 18:55:57 +00:00
|
|
|
RangeError);
|