Intl constructors are no longer able to initialize arbitrary objects as Intl objects. Update tests accordingly.

This commit is contained in:
André Bargull 2015-07-08 19:13:06 +02:00
parent b5efa1dd83
commit 888524ff1d
6 changed files with 42 additions and 81 deletions

View File

@ -3,39 +3,26 @@
/*---
es5id: 10.1.1_1
description: Tests that an object can't be re-initialized as a Collator.
description: Tests that the this-value is ignored in Collator.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.Collator.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with \"new\" as Collator was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with \"new\" as Collator was rejected with wrong error " + error.name + ".");
newObj = Intl.Collator.call(obj);
if (obj === newObj) {
$ERROR("Collator object created with \"new\" was not ignored as this-value.");
}
// variant 2: use constructor as a function
obj = Constructor.call({});
error = undefined;
try {
Intl.Collator.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with constructor as function as Collator was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with constructor as function as Collator was rejected with wrong error " + error.name + ".");
obj = Constructor();
newObj = Intl.Collator.call(obj);
if (obj === newObj) {
$ERROR("Collator object created with constructor as function was not ignored as this-value.");
}
return true;

View File

@ -4,8 +4,8 @@
/*---
es5id: 10.1.2.1_4
description: >
Tests that for non-object values passed as this to Collator a
wrapper object will be initialized and returned.
Tests that non-object values passed as this to Collator are ignored
and a normal collator object will be initialized and returned.
author: Norbert Lindenberg
---*/

View File

@ -3,39 +3,26 @@
/*---
es5id: 11.1.1_1
description: Tests that an object can't be re-initialized as a NumberFormat.
description: Tests that the this-value is ignored in NumberFormat.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.NumberFormat.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with \"new\" as NumberFormat was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with \"new\" as NumberFormat was rejected with wrong error " + error.name + ".");
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
}
// variant 2: use constructor as a function
obj = Constructor.call({});
error = undefined;
try {
Intl.NumberFormat.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with constructor as function as NumberFormat was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with constructor as function as NumberFormat was rejected with wrong error " + error.name + ".");
obj = Constructor();
newObj = Intl.NumberFormat.call(obj);
if (obj === newObj) {
$ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
}
return true;

View File

@ -4,8 +4,8 @@
/*---
es5id: 11.1.2.1_4
description: >
Tests that for non-object values passed as this to NumberFormat a
wrapper object will be initialized and returned.
Tests that non-object values passed as this to NumberFormat are ignored
and a normal number format object will be initialized and returned.
author: Norbert Lindenberg
---*/

View File

@ -3,39 +3,26 @@
/*---
es5id: 12.1.1_1
description: Tests that an object can't be re-initialized as a DateTimeFormat.
description: Tests that the this-value is ignored in DateTimeFormat.
author: Norbert Lindenberg
includes: [testIntl.js]
---*/
testWithIntlConstructors(function (Constructor) {
var obj, error;
var obj, newObj;
// variant 1: use constructor in a "new" expression
obj = new Constructor();
try {
Intl.DateTimeFormat.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with \"new\" as DateTimeFormat was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with \"new\" as DateTimeFormat was rejected with wrong error " + error.name + ".");
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
}
// variant 2: use constructor as a function
obj = Constructor.call({});
error = undefined;
try {
Intl.DateTimeFormat.call(obj);
} catch (e) {
error = e;
}
if (error === undefined) {
$ERROR("Re-initializing object created with constructor as function as DateTimeFormat was not rejected.");
} else if (error.name !== "TypeError") {
$ERROR("Re-initializing object created with constructor as function as DateTimeFormat was rejected with wrong error " + error.name + ".");
obj = Constructor();
newObj = Intl.DateTimeFormat.call(obj);
if (obj === newObj) {
$ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
}
return true;

View File

@ -4,8 +4,8 @@
/*---
es5id: 12.1.2.1_4
description: >
Tests that for non-object values passed as this to DateTimeFormat
a wrapper object will be initialized and returned.
Tests that non-object values passed as this to DateTimeFormat are ignored
and a normal date-time format object will be initialized and returned.
author: Norbert Lindenberg
---*/