| Index: test/mjsunit/es6/collections.js
|
| diff --git a/test/mjsunit/es6/collections.js b/test/mjsunit/es6/collections.js
|
| index 940c0b9d1fab8a314b071e9d5cd6d50fab4cd41d..d8b3374b53cf18a4b8cc55eeb9515331e904fc0e 100644
|
| --- a/test/mjsunit/es6/collections.js
|
| +++ b/test/mjsunit/es6/collections.js
|
| @@ -691,6 +691,34 @@ for (var i = 9; i >= 0; i--) {
|
| assertEquals(4950, accumulated);
|
| })();
|
|
|
| +
|
| +(function TestSetForEachReceiverAsObject() {
|
| + var set = new Set(["1", "2"]);
|
| +
|
| + // When evaluating 'this', primitive values should be coerced to an object.
|
| + // See ECMA-262, Annex C.
|
| + var a = [];
|
| + set.forEach(function() { a.push(this) }, "");
|
| + assertTrue(a[0] !== a[1]);
|
| +
|
| + // When evaluating 'this', non-primitive values are not coerced to an object.
|
| + a = [];
|
| + set.forEach(function() { a.push(this); }, {});
|
| + assertFalse(a[0] !== a[1]);
|
| +})();
|
| +
|
| +
|
| +(function TestSetForEachReceiverAsObjectInStrictMode() {
|
| + var set = new Set(["1", "2"]);
|
| +
|
| + // In strict mode, when evaluating 'this', primitive values should not be
|
| + // coerced to an object. See ECMA-262, Annex C.
|
| + var a = [];
|
| + set.forEach(function() { 'use strict'; a.push(this); }, "");
|
| + assertTrue(a[0] === "" && a[0] === a[1]);
|
| +})();
|
| +
|
| +
|
| (function TestMapForEachInvalidTypes() {
|
| assertThrows(function() {
|
| Map.prototype.map.forEach.call({});
|
| @@ -998,6 +1026,37 @@ for (var i = 9; i >= 0; i--) {
|
| })();
|
|
|
|
|
| +(function TestMapForEachReceiverAsObject() {
|
| + var map = new Map();
|
| + map.set("key1", "value1");
|
| + map.set("key2", "value2");
|
| +
|
| + // When evaluating 'this', primitive values should be coerced to an object.
|
| + // See ECMA-262, Annex C.
|
| + var a = [];
|
| + map.forEach(function() { a.push(this) }, "");
|
| + assertTrue(a[0] !== a[1]);
|
| +
|
| + // When evaluating 'this', non-primitive values are not coerced to an object.
|
| + a = [];
|
| + map.forEach(function() { a.push(this); }, {});
|
| + assertFalse(a[0] !== a[1]);
|
| +})();
|
| +
|
| +
|
| +(function TestMapForEachReceiverAsObjectInStrictMode() {
|
| + var map = new Map();
|
| + map.set("key1", "value1");
|
| + map.set("key2", "value2");
|
| +
|
| + // In strict mode, when evaluating 'this', primitive values should not be
|
| + // coerced to an object. See ECMA-262, Annex C.
|
| + var a = [];
|
| + map.forEach(function() { 'use strict'; a.push(this); }, "");
|
| + assertTrue(a[0] === "" && a[0] === a[1]);
|
| +})();
|
| +
|
| +
|
| // Allows testing iterator-based constructors easily.
|
| var oneAndTwo = new Map();
|
| var k0 = {key: 0};
|
|
|