summaryrefslogtreecommitdiff
path: root/deps/v8/test/intl/list-format/constructor.js
blob: d730516c9c84fea80c644465f5b734bf9b87ce0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2018 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.

// Flags: --harmony-intl-list-format

// ListFormat constructor can't be called as function.
assertThrows(() => Intl.ListFormat(['sr']), TypeError);

// Non-string locale.
// assertThrows(() => new Intl.ListFormat(5), TypeError);

// Invalid locale string.
assertThrows(() => new Intl.ListFormat(['abcdefghi']), RangeError);

assertDoesNotThrow(() => new Intl.ListFormat(['sr'], {}), TypeError);

assertDoesNotThrow(() => new Intl.ListFormat([], {}));

assertDoesNotThrow(() => new Intl.ListFormat(['fr', 'ar'], {}));

assertDoesNotThrow(() => new Intl.ListFormat({0: 'ja', 1:'fr'}, {}));

assertDoesNotThrow(() => new Intl.ListFormat({1: 'ja', 2:'fr'}, {}));

assertDoesNotThrow(() => new Intl.ListFormat(['sr']));

assertDoesNotThrow(() => new Intl.ListFormat());

assertDoesNotThrow(
    () => new Intl.ListFormat(
        ['sr'], {
          style: 'short',
          type: 'unit'
        }));


assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'conjunction'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'disjunction'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'unit'}));

assertThrows(
    () => new Intl.ListFormat(['sr'], {type: 'standard'}),
    RangeError);

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {style: 'long'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {style: 'short'}));

assertThrows(() => new Intl.ListFormat(['sr'], {style: 'narrow'}), RangeError);

assertThrows(
    () => new Intl.ListFormat(['sr'], {style: 'giant'}),
    RangeError);

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'conjunction', style: 'long'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'conjunction', style: 'short'}));

assertThrows(
    () => new Intl.ListFormat(['sr'], {type: 'conjunction', style: 'narrow'}),
    RangeError);

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'long'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'short'}));

assertThrows(
    () => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'narrow'}),
    RangeError);

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'unit', style: 'long'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'unit', style: 'short'}));

assertDoesNotThrow(
    () => new Intl.ListFormat(['sr'], {type: 'unit', style: 'narrow'}));