Skip to content
Snippets Groups Projects
Commit 888524ff authored by André Bargull's avatar André Bargull
Browse files

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

Intl constructors are no longer able to initialize arbitrary objects as Intl objects. Update tests accordingly.
parent b5efa1dd
No related branches found
No related tags found
No related merge requests found
...@@ -3,40 +3,27 @@ ...@@ -3,40 +3,27 @@
/*--- /*---
es5id: 10.1.1_1 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 author: Norbert Lindenberg
includes: [testIntl.js] includes: [testIntl.js]
---*/ ---*/
testWithIntlConstructors(function (Constructor) { testWithIntlConstructors(function (Constructor) {
var obj, error; var obj, newObj;
// variant 1: use constructor in a "new" expression // variant 1: use constructor in a "new" expression
obj = new Constructor(); obj = new Constructor();
try { newObj = Intl.Collator.call(obj);
Intl.Collator.call(obj); if (obj === newObj) {
} catch (e) { $ERROR("Collator object created with \"new\" was not ignored as this-value.");
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 + ".");
} }
// variant 2: use constructor as a function // variant 2: use constructor as a function
obj = Constructor.call({}); obj = Constructor();
error = undefined; newObj = Intl.Collator.call(obj);
try { if (obj === newObj) {
Intl.Collator.call(obj); $ERROR("Collator object created with constructor as function was not ignored as this-value.");
} 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 + ".");
}
return true; return true;
}); });
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
/*--- /*---
es5id: 10.1.2.1_4 es5id: 10.1.2.1_4
description: > description: >
Tests that for non-object values passed as this to Collator a Tests that non-object values passed as this to Collator are ignored
wrapper object will be initialized and returned. and a normal collator object will be initialized and returned.
author: Norbert Lindenberg author: Norbert Lindenberg
---*/ ---*/
......
...@@ -3,40 +3,27 @@ ...@@ -3,40 +3,27 @@
/*--- /*---
es5id: 11.1.1_1 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 author: Norbert Lindenberg
includes: [testIntl.js] includes: [testIntl.js]
---*/ ---*/
testWithIntlConstructors(function (Constructor) { testWithIntlConstructors(function (Constructor) {
var obj, error; var obj, newObj;
// variant 1: use constructor in a "new" expression // variant 1: use constructor in a "new" expression
obj = new Constructor(); obj = new Constructor();
try { newObj = Intl.NumberFormat.call(obj);
Intl.NumberFormat.call(obj); if (obj === newObj) {
} catch (e) { $ERROR("NumberFormat object created with \"new\" was not ignored as this-value.");
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 + ".");
} }
// variant 2: use constructor as a function // variant 2: use constructor as a function
obj = Constructor.call({}); obj = Constructor();
error = undefined; newObj = Intl.NumberFormat.call(obj);
try { if (obj === newObj) {
Intl.NumberFormat.call(obj); $ERROR("NumberFormat object created with constructor as function was not ignored as this-value.");
} 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 + ".");
}
return true; return true;
}); });
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
/*--- /*---
es5id: 11.1.2.1_4 es5id: 11.1.2.1_4
description: > description: >
Tests that for non-object values passed as this to NumberFormat a Tests that non-object values passed as this to NumberFormat are ignored
wrapper object will be initialized and returned. and a normal number format object will be initialized and returned.
author: Norbert Lindenberg author: Norbert Lindenberg
---*/ ---*/
......
...@@ -3,40 +3,27 @@ ...@@ -3,40 +3,27 @@
/*--- /*---
es5id: 12.1.1_1 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 author: Norbert Lindenberg
includes: [testIntl.js] includes: [testIntl.js]
---*/ ---*/
testWithIntlConstructors(function (Constructor) { testWithIntlConstructors(function (Constructor) {
var obj, error; var obj, newObj;
// variant 1: use constructor in a "new" expression // variant 1: use constructor in a "new" expression
obj = new Constructor(); obj = new Constructor();
try { newObj = Intl.DateTimeFormat.call(obj);
Intl.DateTimeFormat.call(obj); if (obj === newObj) {
} catch (e) { $ERROR("DateTimeFormat object created with \"new\" was not ignored as this-value.");
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 + ".");
} }
// variant 2: use constructor as a function // variant 2: use constructor as a function
obj = Constructor.call({}); obj = Constructor();
error = undefined; newObj = Intl.DateTimeFormat.call(obj);
try { if (obj === newObj) {
Intl.DateTimeFormat.call(obj); $ERROR("DateTimeFormat object created with constructor as function was not ignored as this-value.");
} 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 + ".");
}
return true; return true;
}); });
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
/*--- /*---
es5id: 12.1.2.1_4 es5id: 12.1.2.1_4
description: > description: >
Tests that for non-object values passed as this to DateTimeFormat Tests that non-object values passed as this to DateTimeFormat are ignored
a wrapper object will be initialized and returned. and a normal date-time format object will be initialized and returned.
author: Norbert Lindenberg author: Norbert Lindenberg
---*/ ---*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment