Intl.ListFormat: Initial tests. (#1679)

This commit is contained in:
Ms2ger 2018-08-31 21:53:11 +02:00 committed by Leo Balter
parent dbc101606b
commit f98218f831
60 changed files with 2257 additions and 0 deletions

View File

@ -0,0 +1,16 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks error cases for the locales argument to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
1. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
includes: [testIntl.js]
features: [Intl.ListFormat]
---*/
for (const [locales, expectedError] of getInvalidLocaleArguments()) {
assert.throws(expectedError, function() { new Intl.ListFormat(locales) })
}

View File

@ -0,0 +1,25 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-intl.ListFormat
description: >
Verifies the NewTarget check for Intl.ListFormat.
info: |
Intl.ListFormat ([ locales [ , options ]])
1. If NewTarget is undefined, throw a TypeError exception.
features: [Intl.ListFormat]
---*/
assert.throws(TypeError, function() {
Intl.ListFormat();
});
assert.throws(TypeError, function() {
Intl.ListFormat("en");
});
assert.throws(TypeError, function() {
Intl.ListFormat("not-valid-tag");
});

View File

@ -0,0 +1,14 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of a null options argument to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
3. Else
a. Let options be ? ToObject(options).
features: [Intl.ListFormat]
---*/
assert.throws(TypeError, function() { new Intl.ListFormat([], null) })

View File

@ -0,0 +1,44 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks the order of operations on the options argument to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
7. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
14. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long").
16. Let numeric be ? GetOption(options, "numeric", "string", «"always", "auto"», "always").
includes: [compareArray.js]
features: [Intl.ListFormat]
---*/
const callOrder = [];
new Intl.ListFormat([], {
get type() {
callOrder.push("type");
return {
toString() {
callOrder.push("type toString");
return "unit";
}
};
},
get style() {
callOrder.push("style");
return {
toString() {
callOrder.push("style toString");
return "short";
}
};
},
});
assert.compareArray(callOrder, [
"type",
"type toString",
"style",
"style toString",
]);

View File

@ -0,0 +1,32 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of invalid value for the style option to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
9. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long").
features: [Intl.ListFormat]
---*/
const invalidOptions = [
null,
1,
"",
"Long",
"LONG",
"long\0",
"Short",
"SHORT",
"short\0",
"Narrow",
"NARROW",
"narrow\0",
];
for (const invalidOption of invalidOptions) {
assert.throws(RangeError, function() {
new Intl.ListFormat([], {"style": invalidOption});
}, `${invalidOption} is an invalid style option value`);
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of valid values for the style option to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
9. Let s be ? GetOption(options, "style", "string", «"long", "short", "narrow"», "long").
10. Set listFormat.[[Style]] to s.
features: [Intl.ListFormat]
---*/
const validOptions = [
[undefined, "long"],
["long", "long"],
["short", "short"],
["narrow", "narrow"],
[{ toString() { return "narrow"; } }, "narrow"],
];
for (const [validOption, expected] of validOptions) {
const lf = new Intl.ListFormat([], {"style": validOption});
const resolvedOptions = lf.resolvedOptions();
assert.sameValue(resolvedOptions.style, expected);
}

View File

@ -0,0 +1,35 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of non-object option arguments to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
features: [Intl.ListFormat]
---*/
Object.defineProperties(Object.prototype, {
"type": {
value: "unit",
},
"style": {
value: "short",
},
})
const optionsArguments = [
true,
"test",
7,
Symbol(),
];
for (const options of optionsArguments) {
const lf = new Intl.ListFormat([], options);
const resolvedOptions = lf.resolvedOptions();
assert.sameValue(resolvedOptions.type, "unit",
`options argument ${String(options)} should yield the correct value for "type"`);
assert.sameValue(resolvedOptions.style, "short",
`options argument ${String(options)} should yield the correct value for "style"`);
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of non-object option arguments to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
features: [Intl.ListFormat]
---*/
const optionsArguments = [
true,
"test",
7,
Symbol(),
];
for (const options of optionsArguments) {
const lf = new Intl.ListFormat([], options);
const resolvedOptions = lf.resolvedOptions();
assert.sameValue(resolvedOptions.type, "conjunction",
`options argument ${String(options)} should yield the correct value for "type"`);
assert.sameValue(resolvedOptions.style, "long",
`options argument ${String(options)} should yield the correct value for "style"`);
}

View File

@ -0,0 +1,32 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of invalid value for the type option to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
7. Let type be GetOption(options, "type", "string", « "conjunction", "disjunction", "unit" », "conjunction").
features: [Intl.ListFormat]
---*/
const invalidOptions = [
null,
1,
"",
"Conjunction",
"CONJUNCTION",
"conjunction\0",
"Disjunction",
"DISJUNCTION",
"disjunction\0",
"Unit",
"UNIT",
"unit\0",
];
for (const invalidOption of invalidOptions) {
assert.throws(RangeError, function() {
new Intl.ListFormat([], {"type": invalidOption});
}, `${invalidOption} is an invalid type option value`);
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of valid values for the style option to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
7. Let type be GetOption(options, "type", "string", « "conjunction", "disjunction", "unit" », "conjunction").
8. Set listFormat.[[Type]] to type.
features: [Intl.ListFormat]
---*/
const validOptions = [
[undefined, "conjunction"],
["conjunction", "conjunction"],
["disjunction", "disjunction"],
["unit", "unit"],
[{ toString() { return "unit"; } }, "unit"],
];
for (const [validOption, expected] of validOptions) {
const lf = new Intl.ListFormat([], {"type": validOption});
const resolvedOptions = lf.resolvedOptions();
assert.sameValue(resolvedOptions.type, expected);
}

View File

@ -0,0 +1,38 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Checks handling of non-object option arguments to the ListFormat constructor.
info: |
InitializeListFormat (listFormat, locales, options)
features: [Intl.ListFormat]
---*/
Object.defineProperties(Object.prototype, {
"type": {
get() {
throw new Error("Should not call type getter");
}
},
"style": {
get() {
throw new Error("Should not call style getter");
}
},
})
const optionsArguments = [
[],
[[]],
[[], undefined],
];
for (const args of optionsArguments) {
const lf = new Intl.ListFormat(...args);
const resolvedOptions = lf.resolvedOptions();
assert.sameValue(resolvedOptions.type, "conjunction",
`Calling with ${args.length} empty arguments should yield the correct value for "type"`);
assert.sameValue(resolvedOptions.style, "long",
`Calling with ${args.length} empty arguments should yield the correct value for "style"`);
}

View File

@ -0,0 +1,22 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: >
Checks the "length" property of the ListFormat constructor.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
The ListFormat constructor is a standard built-in property of the Intl object.
Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,21 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: >
Checks the "name" property of the ListFormat constructor.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat, "name", {
value: "ListFormat",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,35 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: >
"ListFormat" property of Intl.
info: |
Intl.ListFormat (...)
7 Requirements for Standard Built-in ECMAScript Objects
Unless specified otherwise in this document, the objects, functions, and constructors
described in this standard are subject to the generic requirements and restrictions
specified for standard built-in ECMAScript objects in the ECMAScript 2018 Language
Specification, 9th edition, clause 17, or successor.
17 ECMAScript Standard Built-in Objects:
Every other data property described in clauses 18 through 26 and in Annex B.2 has the
attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }
unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat, "function");
verifyProperty(Intl, "ListFormat", {
value: Intl.ListFormat,
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,17 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: The prototype of the Intl.ListFormat constructor is %FunctionPrototype%.
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Unless otherwise specified every built-in function object has the %FunctionPrototype% object as the initial value of its [[Prototype]] internal slot.
features: [Intl.ListFormat]
---*/
assert.sameValue(
Object.getPrototypeOf(Intl.ListFormat),
Function.prototype,
"Object.getPrototypeOf(Intl.ListFormat) equals the value of Function.prototype"
);

View File

@ -0,0 +1,21 @@
// Copyright 2018 Google Inc., Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: >
Tests that Intl.ListFormat has a supportedLocalesOf property,
and it works as planned.
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat.supportedLocalesOf, "function",
"supportedLocalesOf should be supported.");
const defaultLocale = new Intl.ListFormat().resolvedOptions().locale;
const notSupported = 'zxx'; // "no linguistic content"
const requestedLocales = [defaultLocale, notSupported];
const supportedLocales = Intl.ListFormat.supportedLocalesOf(requestedLocales);
assert.sameValue(supportedLocales.length, 1, 'The length of supported locales list is not 1.');
assert.sameValue(supportedLocales[0], defaultLocale, 'The default locale is not returned in the supported list.');

View File

@ -0,0 +1,29 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: >
Verifies there's no branding check for Intl.ListFormat.supportedLocalesOf().
info: |
Intl.ListFormat.supportedLocalesOf ( locales [, options ])
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.supportedLocalesOf;
const thisValues = [
undefined,
null,
true,
"",
Symbol(),
1,
{},
Intl.ListFormat,
Intl.ListFormat.prototype,
];
for (const thisValue of thisValues) {
const result = fn.call(thisValue);
assert.sameValue(Array.isArray(result), true);
}

View File

@ -0,0 +1,22 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: >
Checks the "length" property of Intl.ListFormat.supportedLocalesOf().
info: |
The value of the length property of the supportedLocalesOf method is 1.
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, has a length property whose value is an integer.
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.supportedLocalesOf, "length", {
value: 1,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,20 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: Checks error cases for the locales argument to the supportedLocalesOf function.
info: |
Intl.ListFormat.supportedLocalesOf ( locales [, options ])
2. Let requestedLocales be CanonicalizeLocaleList(locales).
includes: [testIntl.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Should support Intl.ListFormat.supportedLocalesOf.");
for (const [locales, expectedError] of getInvalidLocaleArguments()) {
assert.throws(expectedError, () => Intl.ListFormat.supportedLocalesOf(locales));
}

View File

@ -0,0 +1,21 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: >
Checks the "name" property of Intl.ListFormat.supportedLocalesOf().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.supportedLocalesOf, "name", {
value: "supportedLocalesOf",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,34 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: Checks handling of invalid values for the localeMatcher option to the supportedLocalesOf function.
info: |
SupportedLocales ( availableLocales, requestedLocales, options )
1. If options is not undefined, then
b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Should support Intl.ListFormat.supportedLocalesOf.");
const invalidOptions = [
null,
1,
"",
"Lookup",
"LOOKUP",
"lookup\0",
"Best fit",
"BEST FIT",
"best\u00a0fit",
];
for (const invalidOption of invalidOptions) {
assert.throws(RangeError, function() {
Intl.ListFormat.supportedLocalesOf([], {"localeMatcher": invalidOption});
}, `${invalidOption} is an invalid localeMatcher option value`);
}

View File

@ -0,0 +1,20 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: Checks handling of a null options argument to the supportedLocalesOf function.
info: |
SupportedLocales ( availableLocales, requestedLocales, options )
1. If options is not undefined, then
a. Let options be ? ToObject(options).
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Should support Intl.ListFormat.supportedLocalesOf.");
assert.throws(TypeError, function() {
Intl.ListFormat.supportedLocalesOf([], null);
}, "Should throw when passing null as the options argument");

View File

@ -0,0 +1,41 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: Checks handling of non-object options arguments to the supportedLocalesOf function.
info: |
SupportedLocales ( availableLocales, requestedLocales, options )
1. If options is not undefined, then
a. Let options be ? ToObject(options).
features: [Intl.ListFormat]
---*/
assert.sameValue(typeof Intl.ListFormat.supportedLocalesOf, "function",
"Should support Intl.ListFormat.supportedLocalesOf.");
let called;
Object.defineProperties(Object.prototype, {
"localeMatcher": {
get() {
++called;
return "best fit";
}
}
});
const optionsArguments = [
true,
"test",
7,
Symbol(),
];
for (const options of optionsArguments) {
called = 0;
const result = Intl.ListFormat.supportedLocalesOf([], options);
assert.sameValue(Array.isArray(result), true, `Expected array from ${String(options)}`);
assert.sameValue(called, 1, `Expected one call from ${String(options)}`);
}

View File

@ -0,0 +1,26 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.RelativeTimeFormat.supportedLocalesOf
description: Checks handling of an undefined options argument to the supportedLocalesOf function.
info: |
SupportedLocales ( availableLocales, requestedLocales, options )
1. If options is not undefined, then
b. Let matcher be ? GetOption(options, "localeMatcher", "string", «"lookup", "best fit"», "best fit").
features: [Intl.RelativeTimeFormat]
---*/
assert.sameValue(typeof Intl.RelativeTimeFormat.supportedLocalesOf, "function",
"Should support Intl.RelativeTimeFormat.supportedLocalesOf.");
Object.defineProperties(Object.prototype, {
"localeMatcher": {
get() { throw new Error("Should not call localeMatcher getter"); }
}
});
assert.sameValue(Array.isArray(Intl.RelativeTimeFormat.supportedLocalesOf()), true, "No arguments");
assert.sameValue(Array.isArray(Intl.RelativeTimeFormat.supportedLocalesOf([])), true, "One argument");
assert.sameValue(Array.isArray(Intl.RelativeTimeFormat.supportedLocalesOf([], undefined)), true, "Two arguments");

View File

@ -0,0 +1,29 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: >
Checks the "supportedLocalesOf" property of the ListFormat prototype object.
info: |
Intl.ListFormat.supportedLocalesOf ( locales [, options ])
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(
typeof Intl.ListFormat.supportedLocalesOf,
"function",
"typeof Intl.ListFormat.supportedLocalesOf is function"
);
verifyProperty(Intl.ListFormat, "supportedLocalesOf", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,34 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.supportedLocalesOf
description: Verifies the type of the return value of Intl.ListFormat.supportedLocalesOf().
info: |
Intl.ListFormat.supportedLocalesOf ( locales [, options ])
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
const result = Intl.ListFormat.supportedLocalesOf("en");
assert.sameValue(Array.isArray(result), true,
"Array.isArray() should return true");
assert.sameValue(Object.getPrototypeOf(result), Array.prototype,
"The prototype should be Array.prototype");
assert.sameValue(Object.isExtensible(result), true,
"Object.isExtensible() should return true");
assert.notSameValue(result.length, 0);
for (let i = 0; i < result.length; ++i) {
verifyProperty(result, String(i), {
"writable": false,
"enumerable": true,
"configurable": false,
});
}
verifyProperty(result, "length", {
"writable": false,
"enumerable": false,
"configurable": false,
});

View File

@ -0,0 +1,19 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Intl.ListFormat instance object extensibility
info: |
17 ECMAScript Standard Built-in Objects:
Unless specified otherwise, the [[Extensible]] internal slot
of a built-in object initially has the value true.
features: [Intl.ListFormat]
---*/
assert.sameValue(
Object.isExtensible(new Intl.ListFormat()),
true,
"Object.isExtensible(new Intl.ListFormat()) returns true"
);

View File

@ -0,0 +1,19 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat
description: Intl.ListFormat instance object is created from %ListFormatPrototype%.
info: |
Intl.ListFormat ([ locales [ , options ]])
2. Let listFormat be ? OrdinaryCreateFromConstructor(NewTarget, "%ListFormatPrototype%", « [[InitializedListFormat]], [[Locale]], [[Type]], [[Style]] »).
features: [Intl.ListFormat]
---*/
const value = new Intl.ListFormat();
assert.sameValue(
Object.getPrototypeOf(value),
Intl.ListFormat.prototype,
"Object.getPrototypeOf(value) equals the value of Intl.ListFormat.prototype"
);

View File

@ -0,0 +1,24 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.constructor
description: Checks the "constructor" property of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.constructor
The initial value of Intl.ListFormat.prototype.constructor is %ListFormat%.
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype, "constructor", {
value: Intl.ListFormat,
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,25 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Verifies the branding check for the "format" function of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.format ([ list ])
2. If Type(lf) is not Object, throw a TypeError exception.
3. If lf does not have an [[InitializedListFormat]] internal slot, throw a TypeError exception.
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.format;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -0,0 +1,51 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US");
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo and bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, and baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, and quux");
}
assert.sameValue(lf.format("foo"), "f, o, and o");

View File

@ -0,0 +1,53 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"type": "disjunction",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo or bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, or baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, or quux");
}
assert.sameValue(lf.format("foo"), "f, o, or o");

View File

@ -0,0 +1,53 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"style": "narrow",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo and bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, and baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, and quux");
}
assert.sameValue(lf.format("foo"), "f, o, and o");

View File

@ -0,0 +1,53 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"style": "short",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo and bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, and baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, and quux");
}
assert.sameValue(lf.format("foo"), "f, o, and o");

View File

@ -0,0 +1,53 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"type": "unit",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo, bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, quux");
}
assert.sameValue(lf.format("foo"), "f, o, o");

View File

@ -0,0 +1,54 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "long",
"type": "unit",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo y bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar y baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz y quux");
}
assert.sameValue(lf.format("foo"), "f, o y o");

View File

@ -0,0 +1,54 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "narrow",
"type": "unit",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo bar baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo bar baz quux");
}
assert.sameValue(lf.format("foo"), "f o o");

View File

@ -0,0 +1,54 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the behavior of Intl.ListFormat.prototype.format() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "short",
"type": "unit",
});
assert.sameValue(typeof lf.format, "function", "format should be supported");
for (const f of transforms) {
assert.sameValue(lf.format(f([])), "");
assert.sameValue(lf.format(f(["foo"])), "foo");
assert.sameValue(lf.format(f(["foo", "bar"])), "foo y bar");
assert.sameValue(lf.format(f(["foo", "bar", "baz"])), "foo, bar, baz");
assert.sameValue(lf.format(f(["foo", "bar", "baz", "quux"])), "foo, bar, baz, quux");
}
assert.sameValue(lf.format("foo"), "f, o, o");

View File

@ -0,0 +1,21 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the "length" property of Intl.ListFormat.prototype.format().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
The ListFormat constructor is a standard built-in property of the Intl object.
Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.format, "length", {
value: 1,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,20 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the "name" property of Intl.ListFormat.prototype.format().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.format, "name", {
value: "format",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,28 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.format
description: Checks the "format" property of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.format ([ list ])
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(
typeof Intl.ListFormat.prototype.format,
"function",
"typeof Intl.ListFormat.prototype.format is function"
);
verifyProperty(Intl.ListFormat.prototype, "format", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,25 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Verifies the branding check for the "formatToParts" function of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.formatToParts([ list ])
2. If Type(lf) is not Object, throw a TypeError exception.
3. If lf does not have an [[InitializedListFormat]] internal slot, throw a TypeError exception.
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.formatToParts;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -0,0 +1,86 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US");
assert.sameValue(typeof lf.formatToParts, "function", "formatToParts should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " and " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,86 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", { "type": "disjunction", });
assert.sameValue(typeof lf.formatToParts, "function", "formatToParts should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " or " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", or " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", or " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", or " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,88 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"style": "narrow",
});
assert.sameValue(typeof lf.formatToParts, "function", "formatToParts should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " and " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,88 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"style": "short",
});
assert.sameValue(typeof lf.formatToParts, "function", "format should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " and " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", and " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,88 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("en-US", {
"type": "unit",
});
assert.sameValue(typeof lf.formatToParts, "function", "format should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,89 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "long",
"type": "unit",
});
assert.sameValue(typeof lf.formatToParts, "function", "format should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " y " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": " y " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": " y " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": " y " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,89 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "narrow",
"type": "unit",
});
assert.sameValue(typeof lf.formatToParts, "function", "format should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": " " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,89 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the behavior of Intl.ListFormat.prototype.formatToParts() in English.
features: [Intl.ListFormat]
locale: [en-US]
---*/
function verifyFormatParts(actual, expected, message) {
assert.sameValue(actual.length, expected.length, `${message}: length`);
for (let i = 0; i < actual.length; ++i) {
assert.sameValue(actual[i].type, expected[i].type, `${message}: parts[${i}].type`);
assert.sameValue(actual[i].value, expected[i].value, `${message}: parts[${i}].value`);
}
}
function CustomIterator(array) {
this.i = 0;
this.array = array;
}
CustomIterator.prototype[Symbol.iterator] = function() {
return this;
}
CustomIterator.prototype.next = function() {
if (this.i >= this.array.length) {
return {
"done": true,
};
}
return {
"value": this.array[this.i++],
"done": false,
};
}
const transforms = [
a => a,
a => a[Symbol.iterator](),
a => new CustomIterator(a),
];
const lf = new Intl.ListFormat("es-ES", {
"style": "short",
"type": "unit",
});
assert.sameValue(typeof lf.formatToParts, "function", "format should be supported");
for (const f of transforms) {
verifyFormatParts(lf.formatToParts(f([])), []);
verifyFormatParts(lf.formatToParts(f(["foo"])), [
{ "type": "element", "value": "foo" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": " y " },
{ "type": "element", "value": "bar" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
]);
verifyFormatParts(lf.formatToParts(f(["foo", "bar", "baz", "quux"])), [
{ "type": "element", "value": "foo" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "bar" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "baz" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "quux" },
]);
}
verifyFormatParts(lf.formatToParts("foo"), [
{ "type": "element", "value": "f" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
{ "type": "literal", "value": ", " },
{ "type": "element", "value": "o" },
]);

View File

@ -0,0 +1,21 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the "length" property of Intl.ListFormat.prototype.formatToParts().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
The ListFormat constructor is a standard built-in property of the Intl object.
Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.formatToParts, "length", {
value: 1,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,20 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the "name" property of Intl.ListFormat.prototype.formatToParts().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.formatToParts, "name", {
value: "formatToParts",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,28 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.formatToParts
description: Checks the "formatToParts" property of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.formatToParts ()
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(
typeof Intl.ListFormat.prototype.formatToParts,
"function",
"typeof Intl.ListFormat.prototype.formatToParts is function"
);
verifyProperty(Intl.ListFormat.prototype, "formatToParts", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,22 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype
description: >
Checks the "prototype" property of the ListFormat constructor.
info: |
Intl.ListFormat.prototype
The value of Intl.ListFormat.prototype is %ListFormatPrototype%.
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat, "prototype", {
writable: false,
enumerable: false,
configurable: false,
});

View File

@ -0,0 +1,25 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Verifies the branding check for the "resolvedOptions" function of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.resolvedOptions()
2. If Type(pr) is not Object, throw a TypeError exception.
3. If pr does not have an [[InitializedListFormat]] internal slot, throw a TypeError exception.
features: [Intl.ListFormat]
---*/
const fn = Intl.ListFormat.prototype.resolvedOptions;
assert.throws(TypeError, () => fn.call(undefined), "undefined");
assert.throws(TypeError, () => fn.call(null), "null");
assert.throws(TypeError, () => fn.call(true), "true");
assert.throws(TypeError, () => fn.call(""), "empty string");
assert.throws(TypeError, () => fn.call(Symbol()), "symbol");
assert.throws(TypeError, () => fn.call(1), "1");
assert.throws(TypeError, () => fn.call({}), "plain object");
assert.throws(TypeError, () => fn.call(Intl.ListFormat), "Intl.ListFormat");
assert.throws(TypeError, () => fn.call(Intl.ListFormat.prototype), "Intl.ListFormat.prototype");

View File

@ -0,0 +1,17 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Verifies that the return value of Intl.ListFormat.prototype.resolvedOptions() is not cached.
info: |
Intl.ListFormat.prototype.resolvedOptions ()
4. Let options be ! ObjectCreate(%ObjectPrototype%).
features: [Intl.ListFormat]
---*/
const lf = new Intl.ListFormat("en-us");
const options1 = lf.resolvedOptions();
const options2 = lf.resolvedOptions();
assert.notSameValue(options1, options2, "Should create a new object each time.");

View File

@ -0,0 +1,21 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Checks the "length" property of Intl.ListFormat.prototype.resolvedOptions().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
The ListFormat constructor is a standard built-in property of the Intl object.
Every built-in function object, including constructors, has a length property whose value is an integer. Unless otherwise specified, this value is equal to the largest number of named arguments shown in the subclause headings for the function description. Optional parameters (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form «...name») are not included in the default argument count.
Unless otherwise specified, the length property of a built-in function object has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.resolvedOptions, "length", {
value: 0,
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,20 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Checks the "name" property of Intl.ListFormat.prototype.resolvedOptions().
info: |
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every built-in function object, including constructors, that is not identified as an anonymous function has a name property whose value is a String. Unless otherwise specified, this value is the name that is given to the function in this specification.
Unless otherwise specified, the name property of a built-in function object, if it exists, has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
verifyProperty(Intl.ListFormat.prototype.resolvedOptions, "name", {
value: "resolvedOptions",
writable: false,
enumerable: false,
configurable: true
});

View File

@ -0,0 +1,28 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Checks the "resolvedOptions" property of the ListFormat prototype object.
info: |
Intl.ListFormat.prototype.resolvedOptions ()
Unless specified otherwise in this document, the objects, functions, and constructors described in this standard are subject to the generic requirements and restrictions specified for standard built-in ECMAScript objects in the ECMAScript 2019 Language Specification, 10th edition, clause 17, or successor.
Every other data property described in clauses 18 through 26 and in Annex B.2 has the attributes { [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
assert.sameValue(
typeof Intl.ListFormat.prototype.resolvedOptions,
"function",
"typeof Intl.ListFormat.prototype.resolvedOptions is function"
);
verifyProperty(Intl.ListFormat.prototype, "resolvedOptions", {
writable: true,
enumerable: false,
configurable: true,
});

View File

@ -0,0 +1,40 @@
// Copyright 2018 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-Intl.ListFormat.prototype.resolvedOptions
description: Checks the properties of the result of Intl.ListFormat.prototype.resolvedOptions().
info: |
Intl.ListFormat.prototype.resolvedOptions ()
4. Let options be ! ObjectCreate(%ObjectPrototype%).
5. For each row of Table 1, except the header row, do
d. Perform ! CreateDataPropertyOrThrow(options, p, v).
includes: [propertyHelper.js]
features: [Intl.ListFormat]
---*/
const lf = new Intl.ListFormat("en-us", { "style": "short", "type": "unit" });
const options = lf.resolvedOptions();
assert.sameValue(Object.getPrototypeOf(options), Object.prototype, "Prototype");
verifyProperty(options, "locale", {
value: "en-US",
writable: true,
enumerable: true,
configurable: true,
});
verifyProperty(options, "type", {
value: "unit",
writable: true,
enumerable: true,
configurable: true,
});
verifyProperty(options, "style", {
value: "short",
writable: true,
enumerable: true,
configurable: true,
});