Upload Kmake

This commit is contained in:
Gorochu
2026-05-26 23:36:42 -07:00
parent ba051b2f74
commit 555ec72358
41615 changed files with 13344630 additions and 1 deletions

View File

@ -0,0 +1,21 @@
// 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.
// Throws only once during construction.
// Check for all getters to prevent regression.
// Preserve the order of getter initialization.
let getCount = 0;
new Intl.ListFormat(['en-US'], {
get localeMatcher() {
assertEquals(0, getCount++);
},
get type() {
assertEquals(1, getCount++);
},
get style() {
assertEquals(2, getCount++);
},
});
assertEquals(3, getCount);

View File

@ -0,0 +1,87 @@
// 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.
// 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'}));
assertDoesNotThrow(
() => new Intl.ListFormat(['sr'], {style: 'narrow'}));
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'}));
assertDoesNotThrow(
() => new Intl.ListFormat(['sr'], {type: 'conjunction', style: 'narrow'}));
assertDoesNotThrow(
() => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'long'}));
assertDoesNotThrow(
() => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'short'}));
assertDoesNotThrow(
() => new Intl.ListFormat(['sr'], {type: 'disjunction', style: 'narrow'}));
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'}));

View File

@ -0,0 +1,96 @@
// 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.
// The following test are not part of the comformance. Just some output in
// English to verify the format does return something reasonable for English.
// It may be changed when we update the CLDR data.
// NOTE: These are UNSPECIFIED behavior in
// http://tc39.github.io/proposal-intl-list-time/
let enLongConjunction = new Intl.ListFormat(
["en"], {style: "long", type: 'conjunction'});
assertEquals('', enLongConjunction.format());
assertEquals('', enLongConjunction.format([]));
assertEquals('a', enLongConjunction.format(['a']));
assertEquals('b', enLongConjunction.format(['b']));
assertEquals('a and b', enLongConjunction.format(['a', 'b']));
assertEquals('a, b, and c', enLongConjunction.format(['a', 'b', 'c']));
assertEquals('a, b, c, and d', enLongConjunction.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, and and',
enLongConjunction.format(['a', 'b', 'c', 'd', 'and']));
let enLongDisjunction = new Intl.ListFormat(
["en"], {style: "long", type: 'disjunction'});
assertEquals('', enLongDisjunction.format());
assertEquals('', enLongDisjunction.format([]));
assertEquals('a', enLongDisjunction.format(['a']));
assertEquals('b', enLongDisjunction.format(['b']));
assertEquals('a or b', enLongDisjunction.format(['a', 'b']));
assertEquals('a, b, or c', enLongDisjunction.format(['a', 'b', 'c']));
assertEquals('a, b, c, or d', enLongDisjunction.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, or or',
enLongDisjunction.format(['a', 'b', 'c', 'd', 'or']));
let enLongUnit = new Intl.ListFormat(
["en"], {style: "long", type: 'unit'});
assertEquals('', enLongUnit.format());
assertEquals('', enLongUnit.format([]));
assertEquals('a', enLongUnit.format(['a']));
assertEquals('b', enLongUnit.format(['b']));
assertEquals('a, b', enLongUnit.format(['a', 'b']));
assertEquals('a, b, c', enLongUnit.format(['a', 'b', 'c']));
assertEquals('a, b, c, d', enLongUnit.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, or', enLongUnit.format(['a', 'b', 'c', 'd', 'or']));
let enShortConjunction = new Intl.ListFormat(
["en"], {style: "short", type: 'conjunction'});
assertEquals('', enShortConjunction.format());
assertEquals('', enShortConjunction.format([]));
assertEquals('a', enShortConjunction.format(['a']));
assertEquals('b', enShortConjunction.format(['b']));
assertEquals('a & b', enShortConjunction.format(['a', 'b']));
assertEquals('a, b, & c', enShortConjunction.format(['a', 'b', 'c']));
assertEquals('a, b, c, & d', enShortConjunction.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, & and',
enShortConjunction.format(['a', 'b', 'c', 'd', 'and']));
let enShortDisjunction = new Intl.ListFormat(
["en"], {style: "short", type: 'disjunction'});
assertEquals('', enShortDisjunction.format());
assertEquals('', enShortDisjunction.format([]));
assertEquals('a', enShortDisjunction.format(['a']));
assertEquals('b', enShortDisjunction.format(['b']));
assertEquals('a or b', enShortDisjunction.format(['a', 'b']));
assertEquals('a, b, or c', enShortDisjunction.format(['a', 'b', 'c']));
assertEquals('a, b, c, or d', enShortDisjunction.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, or or', enShortDisjunction.format(['a', 'b', 'c', 'd', 'or']));
let enShortUnit = new Intl.ListFormat(
["en"], {style: "short", type: 'unit'});
assertEquals('', enShortUnit.format());
assertEquals('', enShortUnit.format([]));
assertEquals('a', enShortUnit.format(['a']));
assertEquals('b', enShortUnit.format(['b']));
assertEquals('a, b', enShortUnit.format(['a', 'b']));
assertEquals('a, b, c', enShortUnit.format(['a', 'b', 'c']));
assertEquals('a, b, c, d', enShortUnit.format(['a', 'b', 'c', 'd']));
assertEquals('a, b, c, d, or', enShortUnit.format(['a', 'b', 'c', 'd', 'or']));
let enNarrowUnit = new Intl.ListFormat(
["en"], {style: "narrow", type: 'unit'});
assertEquals('', enNarrowUnit.format());
assertEquals('', enNarrowUnit.format([]));
assertEquals('a', enNarrowUnit.format(['a']));
assertEquals('b', enNarrowUnit.format(['b']));
assertEquals('a b', enNarrowUnit.format(['a', 'b']));
assertEquals('a b c', enNarrowUnit.format(['a', 'b', 'c']));
assertEquals('a b c d', enNarrowUnit.format(['a', 'b', 'c', 'd']));
assertEquals('a b c d or', enNarrowUnit.format(['a', 'b', 'c', 'd', 'or']));

View File

@ -0,0 +1,94 @@
// 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.
function assertListFormat(listFormat, input) {
var result;
try {
result = listFormat.formatToParts(input);
} catch (e) {
fail('should not throw exception ' + e);
}
assertTrue(Array.isArray(result));
if (input) {
assertTrue(result.length >= input.length * 2 - 1);
for (var i = 0, j = 0; i < result.length; i++) {
assertEquals('string', typeof result[i].value);
assertEquals('string', typeof result[i].type);
assertTrue(result[i].type == 'literal' || result[i].type == 'element');
if (result[i].type == 'element') {
assertEquals(String(input[j++]), result[i].value);
if (i - 1 >= 0) {
assertEquals('literal', result[i - 1].type);
}
if (i + 1 < result.length) {
assertEquals('literal', result[i + 1].type);
}
}
if (result[i].type == 'literal') {
assertTrue(result[i].value.length > 0);
if (i - 1 >= 0) {
assertEquals('element', result[i - 1].type);
}
if (i + 1 < result.length) {
assertEquals('element', result[i + 1].type);
}
}
}
}
}
function testFormatter(listFormat) {
assertListFormat(listFormat, []);
assertListFormat(listFormat, undefined);
assertListFormat(listFormat, ['1']);
assertListFormat(listFormat, ['a']);
assertListFormat(listFormat, ['1', 'b']);
assertListFormat(listFormat, ['1', 'b', '3']);
assertListFormat(listFormat, ['a', 'b']);
assertListFormat(listFormat, ['a', 'b', 'c']);
assertListFormat(listFormat, ['a', 'b', 'c', 'd']);
assertListFormat(listFormat, ['作者', '譚永鋒', '1', (new Date()).toString()]);
assertListFormat(listFormat, ['作者', '譚永鋒', '1', 'b', '3']);
// Tricky cases
assertListFormat(listFormat, [' ', 'b', 'c', 'and']);
assertListFormat(listFormat, [' ', 'b', 'c', 'or']);
assertListFormat(listFormat, ['and']);
assertListFormat(listFormat, ['or']);
assertThrows(() => listFormat.formatToParts(null), TypeError);
assertThrows(() => listFormat.formatToParts([new Date()]), TypeError);
assertThrows(() => listFormat.formatToParts([1]), TypeError);
assertThrows(() => listFormat.formatToParts([1, 'b']), TypeError);
assertThrows(() => listFormat.formatToParts([1, 'b', 3]), TypeError);
assertThrows(() => listFormat.formatToParts([[3, 4]]), TypeError);
assertThrows(() => listFormat.formatToParts([undefined, 'world']), TypeError);
assertThrows(() => listFormat.formatToParts(['hello', undefined]), TypeError);
assertThrows(() => listFormat.formatToParts([undefined]), TypeError);
assertThrows(() => listFormat.formatToParts([null, 'world']), TypeError);
assertThrows(() => listFormat.formatToParts(['hello', null]), TypeError);
assertThrows(() => listFormat.formatToParts([null]), TypeError);
}
testFormatter(new Intl.ListFormat());
testFormatter(new Intl.ListFormat(["en"]));
testFormatter(new Intl.ListFormat(["en"], {style: 'long'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'conjunction'}));
testFormatter(
new Intl.ListFormat(["en"], {style: 'short', type: 'conjunction'}));
testFormatter(
new Intl.ListFormat(["en"], {style: 'narrow', type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'disjunction'}));
testFormatter(
new Intl.ListFormat(["en"], {style: 'short', type: 'disjunction'}));
testFormatter(
new Intl.ListFormat(["en"], {style: 'narrow', type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short', type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow', type: 'unit'}));

65
deps/v8/test/intl/list-format/format.js vendored Normal file
View File

@ -0,0 +1,65 @@
// 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.
function assertListFormat(listFormat, input) {
try {
let result = listFormat.format(input);
assertEquals('string', typeof result);
if (input) {
for (var i = 0; i < input.length; i++) {
assertTrue(result.indexOf(input[i]) >= 0);
}
}
} catch (e) {
fail('should not throw exception ' + e);
}
}
function testFormatter(listFormat) {
assertListFormat(listFormat, []);
assertListFormat(listFormat, undefined);
assertListFormat(listFormat, ['1']);
assertListFormat(listFormat, ['a']);
assertListFormat(listFormat, ['1', 'b']);
assertListFormat(listFormat, ['1', 'b', '3']);
assertListFormat(listFormat, ['a', 'b']);
assertListFormat(listFormat, ['a', 'b', 'c']);
assertListFormat(listFormat, ['a', 'b', 'c', 'd']);
assertListFormat(listFormat, ['作者', '譚永鋒', '1', (new Date()).toString()]);
assertListFormat(listFormat, ['作者', '譚永鋒', '1', 'b', '3']);
assertThrows(() => listFormat.format(null), TypeError);
assertThrows(() => listFormat.format([new Date()]), TypeError);
assertThrows(() => listFormat.format([1]), TypeError);
assertThrows(() => listFormat.format([1, 'b']), TypeError);
assertThrows(() => listFormat.format([1, 'b', 3]), TypeError);
assertThrows(() => listFormat.format([[3, 4]]), TypeError);
assertThrows(() => listFormat.format([undefined, 'world']), TypeError);
assertThrows(() => listFormat.format(['hello', undefined]), TypeError);
assertThrows(() => listFormat.format([undefined]), TypeError);
assertThrows(() => listFormat.format([null, 'world']), TypeError);
assertThrows(() => listFormat.format(['hello', null]), TypeError);
assertThrows(() => listFormat.format([null]), TypeError);
// Test that Cons strings are handled correctly.
let arr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"];
assertListFormat(listFormat, [arr + "n"]);
}
testFormatter(new Intl.ListFormat());
testFormatter(new Intl.ListFormat(["en"]));
testFormatter(new Intl.ListFormat(["en"], {style: 'long'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short', type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow', type: 'conjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short', type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow', type: 'disjunction'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'long', type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'short', type: 'unit'}));
testFormatter(new Intl.ListFormat(["en"], {style: 'narrow', type: 'unit'}));

View File

@ -0,0 +1,155 @@
// 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.
// The following test are not part of the comformance. Just some output in
// Chinese to verify the format does return something reasonable for Chinese.
// It may be changed when we update the CLDR data.
// NOTE: These are UNSPECIFIED behavior in
// http://tc39.github.io/proposal-intl-list-time/
let zhLongConjunction = new Intl.ListFormat(
["zh"], {style: "long", type: 'conjunction'});
var parts;
parts = zhLongConjunction.formatToParts();
assertEquals(0, parts.length);
parts = zhLongConjunction.formatToParts([]);
assertEquals(0, parts.length);
parts = zhLongConjunction.formatToParts(['譚永鋒']);
assertEquals(1, parts.length);
assertEquals('譚永鋒', parts[0].value);
assertEquals('element', parts[0].type);
parts = zhLongConjunction.formatToParts(['譚永鋒', '劉新宇']);
assertEquals(3, parts.length);
assertEquals('譚永鋒', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('和', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('劉新宇', parts[2].value);
assertEquals('element', parts[2].type);
parts = zhLongConjunction.formatToParts(['黄子容', '譚永鋒', '劉新宇']);
assertEquals(5, parts.length);
assertEquals('黄子容', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('、', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('譚永鋒', parts[2].value);
assertEquals('element', parts[2].type);
assertEquals('和', parts[3].value);
assertEquals('literal', parts[3].type);
assertEquals('劉新宇', parts[4].value);
assertEquals('element', parts[4].type);
parts = zhLongConjunction.formatToParts(['黄子容', '譚永鋒', '劉新宇', '朱君毅']);
assertEquals(7, parts.length);
assertEquals('黄子容', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('、', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('譚永鋒', parts[2].value);
assertEquals('element', parts[2].type);
assertEquals('、', parts[3].value);
assertEquals('literal', parts[3].type);
assertEquals('劉新宇', parts[4].value);
assertEquals('element', parts[4].type);
assertEquals('和', parts[5].value);
assertEquals('literal', parts[5].type);
assertEquals('朱君毅', parts[6].value);
assertEquals('element', parts[6].type);
let zhShortDisjunction = new Intl.ListFormat(
["zh"], {style: "short", type: 'disjunction'});
parts = zhShortDisjunction.formatToParts();
assertEquals(0, parts.length);
parts = zhShortDisjunction.formatToParts([]);
assertEquals(0, parts.length);
parts = zhShortDisjunction.formatToParts(['譚永鋒']);
assertEquals(1, parts.length);
assertEquals('譚永鋒', parts[0].value);
assertEquals('element', parts[0].type);
parts = zhShortDisjunction.formatToParts(['譚永鋒', '劉新宇']);
assertEquals(3, parts.length);
assertEquals('譚永鋒', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('或', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('劉新宇', parts[2].value);
assertEquals('element', parts[2].type);
parts = zhShortDisjunction.formatToParts(['黄子容', '譚永鋒', '劉新宇']);
assertEquals(5, parts.length);
assertEquals('黄子容', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('、', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('譚永鋒', parts[2].value);
assertEquals('element', parts[2].type);
assertEquals('或', parts[3].value);
assertEquals('literal', parts[3].type);
assertEquals('劉新宇', parts[4].value);
assertEquals('element', parts[4].type);
parts = zhShortDisjunction.formatToParts(['黄子容', '譚永鋒', '劉新宇', '朱君毅']);
assertEquals(7, parts.length);
assertEquals('黄子容', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('、', parts[1].value);
assertEquals('literal', parts[1].type);
assertEquals('譚永鋒', parts[2].value);
assertEquals('element', parts[2].type);
assertEquals('、', parts[3].value);
assertEquals('literal', parts[3].type);
assertEquals('劉新宇', parts[4].value);
assertEquals('element', parts[4].type);
assertEquals('或', parts[5].value);
assertEquals('literal', parts[5].type);
assertEquals('朱君毅', parts[6].value);
let zhNarrowUnit = new Intl.ListFormat(
["zh"], {style: "narrow", type: 'unit'});
parts = zhNarrowUnit.formatToParts();
assertEquals(0, parts.length);
parts = zhNarrowUnit.formatToParts([]);
assertEquals(0, parts.length);
parts = zhNarrowUnit.formatToParts(['3英哩']);
assertEquals(1, parts.length);
assertEquals('3英哩', parts[0].value);
assertEquals('element', parts[0].type);
parts = zhNarrowUnit.formatToParts(['3英哩', '4碼']);
assertEquals(2, parts.length);
assertEquals('3英哩', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('4碼', parts[1].value);
assertEquals('element', parts[1].type);
parts = zhNarrowUnit.formatToParts(['3英哩', '4碼', '5英尺']);
assertEquals(3, parts.length);
assertEquals('3英哩', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('4碼', parts[1].value);
assertEquals('element', parts[1].type);
assertEquals('5英尺', parts[2].value);
assertEquals('element', parts[2].type);
parts = zhNarrowUnit.formatToParts(['3英哩', '4碼', '5英尺','7英吋']);
assertEquals(4, parts.length);
assertEquals('3英哩', parts[0].value);
assertEquals('element', parts[0].type);
assertEquals('4碼', parts[1].value);
assertEquals('element', parts[1].type);
assertEquals('5英尺', parts[2].value);
assertEquals('element', parts[2].type);
assertEquals('7英吋', parts[3].value);
assertEquals('element', parts[3].type);

View File

@ -0,0 +1,20 @@
// Copyright 2021 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.
// Test Intl.ListFormat call GetOptionsObject instead of ToObject
// https://tc39.es/ecma402/#sec-getoptionsobject
// https://tc39.es/ecma262/#sec-toobject
let testCases = [
null, // Null
true, // Boolean
false, // Boolean
1234, // Number
"string", // String
Symbol('foo'), // Symbol
9007199254740991n // BigInt
];
testCases.forEach(function (testCase) {
assertThrows(() => new Intl.ListFormat("en", testCase), TypeError);
});

View File

@ -0,0 +1,146 @@
// 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.
let listFormat = new Intl.ListFormat();
// The default style is 'long'
assertEquals('long', listFormat.resolvedOptions().style);
// The default type is 'conjunction'
assertEquals('conjunction', listFormat.resolvedOptions().type);
assertEquals(
'short',
(new Intl.ListFormat(['sr'], {style: 'short'}))
.resolvedOptions().style);
assertEquals(
'conjunction',
(new Intl.ListFormat(['sr'], {style: 'short'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {style: 'long'}))
.resolvedOptions().style);
assertEquals(
'conjunction',
(new Intl.ListFormat(['sr'], {style: 'long'}))
.resolvedOptions().type);
assertEquals(
'conjunction',
(new Intl.ListFormat(['sr'], {type: 'conjunction'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {type: 'conjunction'}))
.resolvedOptions().style);
assertEquals(
'disjunction',
(new Intl.ListFormat(['sr'], {type: 'disjunction'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {type: 'disjunction'}))
.resolvedOptions().style);
assertEquals(
'unit',
(new Intl.ListFormat(['sr'], {type: 'unit'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {type: 'unit'}))
.resolvedOptions().style);
assertEquals(
'conjunction',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'conjunction'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'conjunction'}))
.resolvedOptions().style);
assertEquals(
'conjunction',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'conjunction'}))
.resolvedOptions().type);
assertEquals(
'short',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'conjunction'}))
.resolvedOptions().style);
assertEquals(
'disjunction',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'disjunction'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'disjunction'}))
.resolvedOptions().style);
assertEquals(
'disjunction',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'disjunction'}))
.resolvedOptions().type);
assertEquals(
'short',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'disjunction'}))
.resolvedOptions().style);
assertEquals(
'unit',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'unit'}))
.resolvedOptions().type);
assertEquals(
'long',
(new Intl.ListFormat(['sr'], {style: 'long', type: 'unit'}))
.resolvedOptions().style);
assertEquals(
'unit',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'unit'}))
.resolvedOptions().type);
assertEquals(
'short',
(new Intl.ListFormat(['sr'], {style: 'short', type: 'unit'}))
.resolvedOptions().style);
assertEquals(
'unit',
(new Intl.ListFormat(['sr'], {style: 'narrow', type: 'unit'}))
.resolvedOptions().type);
assertEquals(
'narrow',
(new Intl.ListFormat(['sr'], {style: 'narrow', type: 'unit'}))
.resolvedOptions().style);
assertEquals(
'ar',
(new Intl.ListFormat(['ar'])).resolvedOptions().locale);
assertEquals(
'ar',
(new Intl.ListFormat(['ar', 'en'])).resolvedOptions().locale);
assertEquals(
'fr',
(new Intl.ListFormat(['fr', 'en'])).resolvedOptions().locale);
assertEquals(
'ar',
(new Intl.ListFormat(['xyz', 'ar'])).resolvedOptions().locale);

View File

@ -0,0 +1,19 @@
// 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.
assertEquals(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Intl.ListFormat.supportedLocalesOf should be a function");
var undef = Intl.ListFormat.supportedLocalesOf();
assertEquals([], undef);
var empty = Intl.ListFormat.supportedLocalesOf([]);
assertEquals([], empty);
var strLocale = Intl.ListFormat.supportedLocalesOf('sr');
assertEquals('sr', strLocale[0]);
var multiLocale = ['sr-Thai-RS', 'de', 'zh-CN'];
assertEquals(multiLocale,
Intl.ListFormat.supportedLocalesOf(multiLocale, {localeMatcher: "lookup"}));