mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Add tests for the shape of the Intl.RelativeTimeFormat API. (#1596)
* Add Intl.RelativeTimeFormat feature. * Add tests for the shape of the Intl.RelativeTimeFormat API. * fixup! Add tests for the shape of the Intl.RelativeTimeFormat API.
This commit is contained in:
parent
330733eaf3
commit
b4efa8c938
@ -89,6 +89,10 @@ json-superset
|
||||
# https://github.com/tc39/proposal-intl-locale
|
||||
Intl.Locale
|
||||
|
||||
# Intl.RelativeTimeFormat
|
||||
# https://github.com/tc39/proposal-intl-relative-time
|
||||
Intl.RelativeTimeFormat
|
||||
|
||||
# Global
|
||||
# https://github.com/tc39/proposal-global
|
||||
global
|
||||
|
@ -771,6 +771,64 @@ function isCanonicalizedStructurallyValidLanguageTag(locale) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array of error cases handled by CanonicalizeLocaleList().
|
||||
*/
|
||||
function getInvalidLocaleArguments() {
|
||||
function CustomError() {}
|
||||
|
||||
var topLevelErrors = [
|
||||
// fails ToObject
|
||||
[null, TypeError],
|
||||
|
||||
// fails Get
|
||||
[{ get length() { throw new CustomError(); } }, CustomError],
|
||||
|
||||
// fail ToLength
|
||||
[{ length: Symbol.toPrimitive }, TypeError],
|
||||
[{ length: { get [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError],
|
||||
[{ length: { [Symbol.toPrimitive]() { throw new CustomError(); } } }, CustomError],
|
||||
[{ length: { get valueOf() { throw new CustomError(); } } }, CustomError],
|
||||
[{ length: { valueOf() { throw new CustomError(); } } }, CustomError],
|
||||
[{ length: { get toString() { throw new CustomError(); } } }, CustomError],
|
||||
[{ length: { toString() { throw new CustomError(); } } }, CustomError],
|
||||
|
||||
// fail type check
|
||||
[[undefined], TypeError],
|
||||
[[null], TypeError],
|
||||
[[true], TypeError],
|
||||
[[Symbol.toPrimitive], TypeError],
|
||||
[[1], TypeError],
|
||||
[[0.1], TypeError],
|
||||
[[NaN], TypeError],
|
||||
];
|
||||
|
||||
var invalidLanguageTags = [
|
||||
"", // empty tag
|
||||
"i", // singleton alone
|
||||
"x", // private use without subtag
|
||||
"u", // extension singleton in first place
|
||||
"419", // region code in first place
|
||||
"u-nu-latn-cu-bob", // extension sequence without language
|
||||
"hans-cmn-cn", // "hans" could theoretically be a 4-letter language code,
|
||||
// but those can't be followed by extlang codes.
|
||||
"cmn-hans-cn-u-u", // duplicate singleton
|
||||
"cmn-hans-cn-t-u-ca-u", // duplicate singleton
|
||||
"de-gregory-gregory", // duplicate variant
|
||||
"*", // language range
|
||||
"de-*", // language range
|
||||
"中文", // non-ASCII letters
|
||||
"en-ß", // non-ASCII letters
|
||||
"ıd" // non-ASCII letters
|
||||
];
|
||||
|
||||
return topLevelErrors.concat(
|
||||
invalidLanguageTags.map(tag => [tag, RangeError]),
|
||||
invalidLanguageTags.map(tag => [[tag], RangeError]),
|
||||
invalidLanguageTags.map(tag => [["en", tag], RangeError]),
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests whether the named options property is correctly handled by the given constructor.
|
||||
* @param {object} Constructor the constructor to test.
|
||||
|
@ -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.RelativeTimeFormat
|
||||
description: Checks error cases for the locales argument to the RelativeTimeFormat constructor.
|
||||
info: |
|
||||
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
|
||||
3. Let _requestedLocales_ be ? CanonicalizeLocaleList(_locales_).
|
||||
includes: [testIntl.js]
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
for (const [locales, expectedError] of getInvalidLocaleArguments()) {
|
||||
assert.throws(expectedError, function() { new Intl.RelativeTimeFormat(locales) })
|
||||
}
|
@ -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.RelativeTimeFormat
|
||||
description: >
|
||||
Verifies the NewTarget check for Intl.RelativeTimeFormat.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat ([ locales [ , options ]])
|
||||
|
||||
1. If NewTarget is undefined, throw a TypeError exception.
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Intl.RelativeTimeFormat();
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Intl.RelativeTimeFormat("en");
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Intl.RelativeTimeFormat("not-valid-tag");
|
||||
});
|
@ -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.RelativeTimeFormat
|
||||
description: Checks handling of a null options argument to the RelativeTimeFormat constructor.
|
||||
info: |
|
||||
InitializeRelativeTimeFormat (relativeTimeFormat, locales, options)
|
||||
5. Else
|
||||
a. Let options be ? ToObject(options).
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() { new Intl.RelativeTimeFormat([], null) })
|
@ -0,0 +1,55 @@
|
||||
// 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
|
||||
description: Checks the order of operations on the options argument to the RelativeTimeFormat constructor.
|
||||
info: |
|
||||
InitializeRelativeTimeFormat (relativeTimeFormat, 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const callOrder = [];
|
||||
|
||||
new Intl.RelativeTimeFormat([], {
|
||||
get localeMatcher() {
|
||||
callOrder.push("localeMatcher");
|
||||
return {
|
||||
toString() {
|
||||
callOrder.push("localeMatcher toString");
|
||||
return "best fit";
|
||||
}
|
||||
};
|
||||
},
|
||||
get style() {
|
||||
callOrder.push("style");
|
||||
return {
|
||||
toString() {
|
||||
callOrder.push("style toString");
|
||||
return "long";
|
||||
}
|
||||
};
|
||||
},
|
||||
get numeric() {
|
||||
callOrder.push("numeric");
|
||||
return {
|
||||
toString() {
|
||||
callOrder.push("numeric toString");
|
||||
return "always";
|
||||
}
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
assert.compareArray(callOrder, [
|
||||
"localeMatcher",
|
||||
"localeMatcher toString",
|
||||
"style",
|
||||
"style toString",
|
||||
"numeric",
|
||||
"numeric toString",
|
||||
]);
|
22
test/intl402/RelativeTimeFormat/constructor/length.js
Normal file
22
test/intl402/RelativeTimeFormat/constructor/length.js
Normal 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.RelativeTimeFormat
|
||||
description: >
|
||||
Checks the "length" property of the RelativeTimeFormat 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 RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
21
test/intl402/RelativeTimeFormat/constructor/name.js
Normal file
21
test/intl402/RelativeTimeFormat/constructor/name.js
Normal 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.RelativeTimeFormat
|
||||
description: >
|
||||
Checks the "name" property of the RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat, "name", {
|
||||
value: "RelativeTimeFormat",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
35
test/intl402/RelativeTimeFormat/constructor/prop-desc.js
Normal file
35
test/intl402/RelativeTimeFormat/constructor/prop-desc.js
Normal 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.RelativeTimeFormat
|
||||
description: >
|
||||
"RelativeTimeFormat" property of Intl.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat (...)
|
||||
|
||||
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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(typeof Intl.RelativeTimeFormat, "function");
|
||||
|
||||
verifyProperty(Intl, "RelativeTimeFormat", {
|
||||
value: Intl.RelativeTimeFormat,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
17
test/intl402/RelativeTimeFormat/constructor/prototype.js
vendored
Normal file
17
test/intl402/RelativeTimeFormat/constructor/prototype.js
vendored
Normal 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.RelativeTimeFormat
|
||||
description: The prototype of the Intl.RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(Intl.RelativeTimeFormat),
|
||||
Function.prototype,
|
||||
"Object.getPrototypeOf(Intl.RelativeTimeFormat) equals the value of Function.prototype"
|
||||
);
|
@ -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.RelativeTimeFormat.supportedLocalesOf
|
||||
description: >
|
||||
Verifies there's no branding check for Intl.RelativeTimeFormat.supportedLocalesOf().
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.supportedLocalesOf ( locales [, options ])
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const fn = Intl.RelativeTimeFormat.supportedLocalesOf;
|
||||
const thisValues = [
|
||||
undefined,
|
||||
null,
|
||||
true,
|
||||
"",
|
||||
Symbol(),
|
||||
1,
|
||||
{},
|
||||
Intl.RelativeTimeFormat,
|
||||
Intl.RelativeTimeFormat.prototype,
|
||||
];
|
||||
|
||||
for (const thisValue of thisValues) {
|
||||
const result = fn.call(thisValue);
|
||||
assert.sameValue(Array.isArray(result), true);
|
||||
}
|
@ -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.RelativeTimeFormat.supportedLocalesOf
|
||||
description: >
|
||||
Checks the "length" property of Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.supportedLocalesOf, "length", {
|
||||
value: 1,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
@ -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.RelativeTimeFormat.supportedLocalesOf
|
||||
description: >
|
||||
Checks the "name" property of Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.supportedLocalesOf, "name", {
|
||||
value: "supportedLocalesOf",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
@ -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.RelativeTimeFormat.supportedLocalesOf
|
||||
description: >
|
||||
Checks the "supportedLocalesOf" property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.RelativeTimeFormat.supportedLocalesOf,
|
||||
"function",
|
||||
"typeof Intl.RelativeTimeFormat.supportedLocalesOf is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat, "supportedLocalesOf", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
|
20
test/intl402/RelativeTimeFormat/instance/extensibility.js
Normal file
20
test/intl402/RelativeTimeFormat/instance/extensibility.js
Normal 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.RelativeTimeFormat
|
||||
description: >
|
||||
Intl.RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Object.isExtensible(new Intl.RelativeTimeFormat()),
|
||||
true,
|
||||
"Object.isExtensible(new Intl.RelativeTimeFormat()) returns true"
|
||||
);
|
20
test/intl402/RelativeTimeFormat/instance/prototype.js
vendored
Normal file
20
test/intl402/RelativeTimeFormat/instance/prototype.js
vendored
Normal 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.RelativeTimeFormat
|
||||
description: >
|
||||
Intl.RelativeTimeFormat instance object is created from %RelativeTimeFormatPrototype%.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat ([ locales [ , options ]])
|
||||
|
||||
2. Let relativeTimeFormat be ! OrdinaryCreateFromConstructor(NewTarget, "%RelativeTimeFormatPrototype%").
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const value = new Intl.RelativeTimeFormat();
|
||||
assert.sameValue(
|
||||
Object.getPrototypeOf(value),
|
||||
Intl.RelativeTimeFormat.prototype,
|
||||
"Object.getPrototypeOf(value) equals the value of Intl.RelativeTimeFormat.prototype"
|
||||
);
|
24
test/intl402/RelativeTimeFormat/prototype/constructor/prop-desc.js
vendored
Normal file
24
test/intl402/RelativeTimeFormat/prototype/constructor/prop-desc.js
vendored
Normal 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.RelativeTimeFormat.prototype.constructor
|
||||
description: Checks the "constructor" property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype.constructor
|
||||
|
||||
The initial value of Intl.RelativeTimeFormat.prototype.constructor is %RelativeTimeFormat%.
|
||||
|
||||
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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype, "constructor", {
|
||||
value: Intl.RelativeTimeFormat,
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
24
test/intl402/RelativeTimeFormat/prototype/format/branding.js
vendored
Normal file
24
test/intl402/RelativeTimeFormat/prototype/format/branding.js
vendored
Normal 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.RelativeTimeFormat.prototype.format
|
||||
description: Verifies the branding check for the "format" function of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype.format( value, unit )
|
||||
|
||||
2. If Type(relativeTimeFormat) is not Object or relativeTimeFormat does not have an [[InitializedRelativeTimeFormat]] internal slot whose value is true, throw a TypeError exception.
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const fn = Intl.RelativeTimeFormat.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.RelativeTimeFormat), "Intl.RelativeTimeFormat");
|
||||
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
|
21
test/intl402/RelativeTimeFormat/prototype/format/length.js
vendored
Normal file
21
test/intl402/RelativeTimeFormat/prototype/format/length.js
vendored
Normal 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.RelativeTimeFormat.prototype.format
|
||||
description: Checks the "length" property of Intl.RelativeTimeFormat.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 RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.format, "length", {
|
||||
value: 2,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
20
test/intl402/RelativeTimeFormat/prototype/format/name.js
vendored
Normal file
20
test/intl402/RelativeTimeFormat/prototype/format/name.js
vendored
Normal 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.RelativeTimeFormat.prototype.format
|
||||
description: Checks the "name" property of Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.format, "name", {
|
||||
value: "format",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
28
test/intl402/RelativeTimeFormat/prototype/format/prop-desc.js
vendored
Normal file
28
test/intl402/RelativeTimeFormat/prototype/format/prop-desc.js
vendored
Normal 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.RelativeTimeFormat.prototype.format
|
||||
description: Checks the "format" property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype.format ()
|
||||
|
||||
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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.RelativeTimeFormat.prototype.format,
|
||||
"function",
|
||||
"typeof Intl.RelativeTimeFormat.prototype.format is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype, "format", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
|
24
test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js
vendored
Normal file
24
test/intl402/RelativeTimeFormat/prototype/formatToParts/branding.js
vendored
Normal 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.RelativeTimeFormat.prototype.formatToParts
|
||||
description: Verifies the branding check for the "formatToParts" function of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype.formatToParts( value, unit )
|
||||
|
||||
2. If Type(relativeTimeFormat) is not Object or relativeTimeFormat does not have an [[InitializedRelativeTimeFormat]] internal slot whose value is true, throw a TypeError exception.
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const fn = Intl.RelativeTimeFormat.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.RelativeTimeFormat), "Intl.RelativeTimeFormat");
|
||||
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
|
21
test/intl402/RelativeTimeFormat/prototype/formatToParts/length.js
vendored
Normal file
21
test/intl402/RelativeTimeFormat/prototype/formatToParts/length.js
vendored
Normal 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.RelativeTimeFormat.prototype.formatToParts
|
||||
description: Checks the "length" property of Intl.RelativeTimeFormat.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 RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.formatToParts, "length", {
|
||||
value: 2,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
20
test/intl402/RelativeTimeFormat/prototype/formatToParts/name.js
vendored
Normal file
20
test/intl402/RelativeTimeFormat/prototype/formatToParts/name.js
vendored
Normal 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.RelativeTimeFormat.prototype.formatToParts
|
||||
description: Checks the "name" property of Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.formatToParts, "name", {
|
||||
value: "formatToParts",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
28
test/intl402/RelativeTimeFormat/prototype/formatToParts/prop-desc.js
vendored
Normal file
28
test/intl402/RelativeTimeFormat/prototype/formatToParts/prop-desc.js
vendored
Normal 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.RelativeTimeFormat.prototype.formatToParts
|
||||
description: Checks the "formatToParts" property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.RelativeTimeFormat.prototype.formatToParts,
|
||||
"function",
|
||||
"typeof Intl.RelativeTimeFormat.prototype.formatToParts is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype, "formatToParts", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
|
22
test/intl402/RelativeTimeFormat/prototype/prop-desc.js
vendored
Normal file
22
test/intl402/RelativeTimeFormat/prototype/prop-desc.js
vendored
Normal 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.RelativeTimeFormat.prototype
|
||||
description: >
|
||||
Checks the "prototype" property of the RelativeTimeFormat constructor.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype
|
||||
|
||||
The value of Intl.RelativeTimeFormat.prototype is %RelativeTimeFormatPrototype%.
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: false }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat, "prototype", {
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: false,
|
||||
});
|
24
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js
vendored
Normal file
24
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/branding.js
vendored
Normal 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.RelativeTimeFormat.prototype.resolvedOptions
|
||||
description: Verifies the branding check for the "resolvedOptions" function of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype.resolvedOptions( value, unit )
|
||||
|
||||
2. If Type(relativeTimeFormat) is not Object or relativeTimeFormat does not have an [[InitializedRelativeTimeFormat]] internal slot whose value is true, throw a TypeError exception.
|
||||
features: [Intl.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
const fn = Intl.RelativeTimeFormat.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.RelativeTimeFormat), "Intl.RelativeTimeFormat");
|
||||
assert.throws(TypeError, () => fn.call(Intl.RelativeTimeFormat.prototype), "Intl.RelativeTimeFormat.prototype");
|
21
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/length.js
vendored
Normal file
21
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/length.js
vendored
Normal 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.RelativeTimeFormat.prototype.resolvedOptions
|
||||
description: Checks the "length" property of Intl.RelativeTimeFormat.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 RelativeTimeFormat 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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.resolvedOptions, "length", {
|
||||
value: 0,
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
20
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/name.js
vendored
Normal file
20
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/name.js
vendored
Normal 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.RelativeTimeFormat.prototype.resolvedOptions
|
||||
description: Checks the "name" property of Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype.resolvedOptions, "name", {
|
||||
value: "resolvedOptions",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
28
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/prop-desc.js
vendored
Normal file
28
test/intl402/RelativeTimeFormat/prototype/resolvedOptions/prop-desc.js
vendored
Normal 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.RelativeTimeFormat.prototype.resolvedOptions
|
||||
description: Checks the "resolvedOptions" property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.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.RelativeTimeFormat]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
typeof Intl.RelativeTimeFormat.prototype.resolvedOptions,
|
||||
"function",
|
||||
"typeof Intl.RelativeTimeFormat.prototype.resolvedOptions is function"
|
||||
);
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype, "resolvedOptions", {
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
|
23
test/intl402/RelativeTimeFormat/prototype/toStringTag/toStringTag.js
vendored
Normal file
23
test/intl402/RelativeTimeFormat/prototype/toStringTag/toStringTag.js
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
// 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.prototype-@@tostringtag
|
||||
description: >
|
||||
Checks the @@toStringTag property of the RelativeTimeFormat prototype object.
|
||||
info: |
|
||||
Intl.RelativeTimeFormat.prototype[ @@toStringTag ]
|
||||
|
||||
The initial value of the @@toStringTag property is the string value "Object".
|
||||
|
||||
This property has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }.
|
||||
includes: [propertyHelper.js]
|
||||
features: [Intl.RelativeTimeFormat, Symbol.toStringTag]
|
||||
---*/
|
||||
|
||||
verifyProperty(Intl.RelativeTimeFormat.prototype, Symbol.toStringTag, {
|
||||
value: "Object",
|
||||
writable: false,
|
||||
enumerable: false,
|
||||
configurable: true
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user