mirror of https://github.com/tc39/test262.git
Intl constructors are no longer able to initialize arbitrary objects as Intl objects. Update tests accordingly.
This commit is contained in:
parent
b5efa1dd83
commit
888524ff1d
|
@ -3,40 +3,27 @@
|
|||
|
||||
/*---
|
||||
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;
|
||||
newObj = Intl.Collator.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("Collator object created with \"new\" was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
// variant 2: use constructor as a function
|
||||
obj = Constructor.call({});
|
||||
error = undefined;
|
||||
try {
|
||||
Intl.Collator.call(obj);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
obj = Constructor();
|
||||
newObj = Intl.Collator.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("Collator object created with constructor as function was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -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
|
||||
---*/
|
||||
|
||||
|
|
|
@ -3,40 +3,27 @@
|
|||
|
||||
/*---
|
||||
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;
|
||||
newObj = Intl.NumberFormat.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
// variant 2: use constructor as a function
|
||||
obj = Constructor.call({});
|
||||
error = undefined;
|
||||
try {
|
||||
Intl.NumberFormat.call(obj);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
obj = Constructor();
|
||||
newObj = Intl.NumberFormat.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -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
|
||||
---*/
|
||||
|
||||
|
|
|
@ -3,40 +3,27 @@
|
|||
|
||||
/*---
|
||||
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;
|
||||
newObj = Intl.DateTimeFormat.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
// variant 2: use constructor as a function
|
||||
obj = Constructor.call({});
|
||||
error = undefined;
|
||||
try {
|
||||
Intl.DateTimeFormat.call(obj);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
obj = Constructor();
|
||||
newObj = Intl.DateTimeFormat.call(obj);
|
||||
if (obj === newObj) {
|
||||
$ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
|
||||
}
|
||||
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 + ".");
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
});
|
||||
|
|
|
@ -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
|
||||
---*/
|
||||
|
||||
|
|
Loading…
Reference in New Issue