Chromium Code Reviews| Index: test/mjsunit/array-iteration.js |
| diff --git a/test/mjsunit/array-iteration.js b/test/mjsunit/array-iteration.js |
| index d11f984bee43be0a7e54794c52d2e05421bd74bb..ad5c54582eeffc3f15b665576477702e8d8da721 100644 |
| --- a/test/mjsunit/array-iteration.js |
| +++ b/test/mjsunit/array-iteration.js |
| @@ -68,6 +68,16 @@ |
| assertEquals(3, count); |
| for (var i in a) assertEquals(2, a[i]); |
| + // Create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
|
arv (Not doing code reviews)
2014/09/12 16:29:17
nit
a = [];
|
| + [1,2].filter(function() { a.push(this) }, ""); |
|
arv (Not doing code reviews)
2014/09/12 16:29:17
nit, space after comma
|
| + assertTrue(a[0] !== a[1]); |
| + |
| + // Do not create a new object in each function call when receiver is a primitive value. |
|
wingo
2014/09/15 09:12:21
"when receiver is not a primitive value" here, and
Diego Pino
2014/09/16 10:45:46
Acknowledged.
|
| + a = new Array(); |
| + [1,2].filter(function() { a.push(this) }, {}); |
| + assertFalse(a[0] !== a[1]); |
| + |
| })(); |
| @@ -109,6 +119,16 @@ |
| a.forEach(function(n) { count++; }); |
| assertEquals(1, count); |
| + // Create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].forEach(function() { a.push(this) }, ""); |
| + assertTrue(a[0] !== a[1]); |
| + |
| + // Do not create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].forEach(function() { a.push(this) }, {}); |
| + assertFalse(a[0] !== a[1]); |
| + |
| })(); |
| @@ -149,6 +169,16 @@ |
| assertTrue(a.every(function(n) { count++; return n == 2; })); |
| assertEquals(2, count); |
| + // Create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].every(function() { a.push(this); return true; }, ""); |
| + assertTrue(a[0] !== a[1]); |
| + |
| + // Do not create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].every(function() { a.push(this); return true; }, {}); |
| + assertFalse(a[0] !== a[1]); |
| + |
| })(); |
| // |
| @@ -186,6 +216,16 @@ |
| a = a.map(function(n) { return 2*n; }); |
| for (var i in a) assertEquals(4, a[i]); |
| + // Create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].map(function() { a.push(this) }, ""); |
| + assertTrue(a[0] !== a[1]); |
| + |
| + // Do not create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].map(function() { a.push(this) }, {}); |
| + assertFalse(a[0] !== a[1]); |
| + |
| })(); |
| // |
| @@ -224,4 +264,14 @@ |
| assertTrue(a.some(function(n) { count++; return n == 2; })); |
| assertEquals(2, count); |
| + // Create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].some(function() { a.push(this) }, ""); |
| + assertTrue(a[0] !== a[1]); |
| + |
| + // Do not create a new object in each function call when receiver is a primitive value. |
| + a = new Array(); |
| + [1,2].some(function() { a.push(this) }, {}); |
| + assertFalse(a[0] !== a[1]); |
| + |
| })(); |