mirror of https://github.com/tc39/test262.git
Also test Intl.PluralRules if available
This commit is contained in:
parent
48173672f2
commit
56323fe2dd
|
@ -21,6 +21,14 @@ author: Norbert Lindenberg
|
||||||
*/
|
*/
|
||||||
function testWithIntlConstructors(f) {
|
function testWithIntlConstructors(f) {
|
||||||
var constructors = ["Collator", "NumberFormat", "DateTimeFormat"];
|
var constructors = ["Collator", "NumberFormat", "DateTimeFormat"];
|
||||||
|
|
||||||
|
// Optionally supported Intl constructors.
|
||||||
|
["PluralRules"].forEach(function(constructor) {
|
||||||
|
if (typeof Intl[constructor] === "function") {
|
||||||
|
constructors[constructors.length] = constructor;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
constructors.forEach(function (constructor) {
|
constructors.forEach(function (constructor) {
|
||||||
var Constructor = Intl[constructor];
|
var Constructor = Intl[constructor];
|
||||||
try {
|
try {
|
||||||
|
@ -99,7 +107,7 @@ function taintArray() {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets locale support info for the given constructor object, which must be one
|
* Gets locale support info for the given constructor object, which must be one
|
||||||
* of Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat.
|
* of Intl constructors.
|
||||||
* @param {object} Constructor the constructor for which to get locale support info
|
* @param {object} Constructor the constructor for which to get locale support info
|
||||||
* @return {object} locale support info with the following properties:
|
* @return {object} locale support info with the following properties:
|
||||||
* supported: array of fully supported language tags
|
* supported: array of fully supported language tags
|
||||||
|
|
|
@ -17,6 +17,13 @@ testWithIntlConstructors(function (Constructor) {
|
||||||
assert.notSameValue(obj, newObj, "Collator object created with \"new\" was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "Collator object created with \"new\" was not ignored as this-value.");
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
|
if (Constructor !== Intl.Collator &&
|
||||||
|
Constructor !== Intl.NumberFormat &&
|
||||||
|
Constructor !== Intl.DateTimeFormat)
|
||||||
|
{
|
||||||
|
// Newer Intl constructors are not callable as a function.
|
||||||
|
return;
|
||||||
|
}
|
||||||
obj = Constructor();
|
obj = Constructor();
|
||||||
newObj = Intl.Collator.call(obj);
|
newObj = Intl.Collator.call(obj);
|
||||||
assert.notSameValue(obj, newObj, "Collator object created with constructor as function was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "Collator object created with constructor as function was not ignored as this-value.");
|
||||||
|
|
|
@ -22,6 +22,13 @@ testWithIntlConstructors(function (Constructor) {
|
||||||
assert.notSameValue(obj, newObj, "DateTimeFormat object created with \"new\" was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "DateTimeFormat object created with \"new\" was not ignored as this-value.");
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
|
if (Constructor !== Intl.Collator &&
|
||||||
|
Constructor !== Intl.NumberFormat &&
|
||||||
|
Constructor !== Intl.DateTimeFormat)
|
||||||
|
{
|
||||||
|
// Newer Intl constructors are not callable as a function.
|
||||||
|
return;
|
||||||
|
}
|
||||||
obj = Constructor();
|
obj = Constructor();
|
||||||
newObj = Intl.DateTimeFormat.call(obj);
|
newObj = Intl.DateTimeFormat.call(obj);
|
||||||
assert.notSameValue(obj, newObj, "DateTimeFormat object created with constructor as function was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "DateTimeFormat object created with constructor as function was not ignored as this-value.");
|
||||||
|
|
|
@ -22,6 +22,13 @@ testWithIntlConstructors(function (Constructor) {
|
||||||
assert.notSameValue(obj, newObj, "NumberFormat object created with \"new\" was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "NumberFormat object created with \"new\" was not ignored as this-value.");
|
||||||
|
|
||||||
// variant 2: use constructor as a function
|
// variant 2: use constructor as a function
|
||||||
|
if (Constructor !== Intl.Collator &&
|
||||||
|
Constructor !== Intl.NumberFormat &&
|
||||||
|
Constructor !== Intl.DateTimeFormat)
|
||||||
|
{
|
||||||
|
// Newer Intl constructors are not callable as a function.
|
||||||
|
return;
|
||||||
|
}
|
||||||
obj = Constructor();
|
obj = Constructor();
|
||||||
newObj = Intl.NumberFormat.call(obj);
|
newObj = Intl.NumberFormat.call(obj);
|
||||||
assert.notSameValue(obj, newObj, "NumberFormat object created with constructor as function was not ignored as this-value.");
|
assert.notSameValue(obj, newObj, "NumberFormat object created with constructor as function was not ignored as this-value.");
|
||||||
|
|
Loading…
Reference in New Issue