Index: test/mjsunit/harmony/array-concat.js |
diff --git a/test/mjsunit/harmony/array-concat.js b/test/mjsunit/harmony/array-concat.js |
index 738c81a45753d44653f0e0e6aabf6c4fbde4e4d0..57ae048e2d81c030b61fae423a1765df08420305 100644 |
--- a/test/mjsunit/harmony/array-concat.js |
+++ b/test/mjsunit/harmony/array-concat.js |
@@ -40,6 +40,57 @@ |
})(); |
+(function testConcatArrayLikeStringLength() { |
+ "use strict"; |
+ var obj = { |
+ "length": "6", |
+ "1": "A", |
+ "3": "B", |
+ "5": "C" |
+ }; |
+ obj[Symbol.isConcatSpreadable] = true; |
+ var obj2 = { length: 3, "0": "0", "1": "1", "2": "2" }; |
+ var arr = ["X", "Y", "Z"]; |
+ assertEquals([void 0, "A", void 0, "B", void 0, "C", |
+ { "length": 3, "0": "0", "1": "1", "2": "2" }, |
+ "X", "Y", "Z"], Array.prototype.concat.call(obj, obj2, arr)); |
+})(); |
+ |
+ |
+(function testConcatArrayLikeNegativeLength() { |
+ "use strict"; |
+ var obj = { |
+ "length": -6, |
+ "1": "A", |
+ "3": "B", |
+ "5": "C" |
+ }; |
+ obj[Symbol.isConcatSpreadable] = true; |
+ assertEquals([], [].concat(obj)); |
+ obj.length = -6.7; |
+ assertEquals([], [].concat(obj)); |
+ obj.length = "-6"; |
+ assertEquals([], [].concat(obj)); |
+})(); |
+ |
+ |
+(function testConcatArrayLikeToLengthThrows() { |
+ "use strict"; |
+ var obj = { |
+ "length": {valueOf: null, toString: null}, |
Dmitry Lomov (no reviews)
2014/12/15 07:23:51
Add a test where `toString` and `valueOf` throw an
caitp (gmail)
2014/12/15 18:15:29
Done
|
+ "1": "A", |
+ "3": "B", |
+ "5": "C" |
+ }; |
+ obj[Symbol.isConcatSpreadable] = true; |
+ var obj2 = { length: 3, "0": "0", "1": "1", "2": "2" }; |
+ var arr = ["X", "Y", "Z"]; |
+ assertThrows(function() { |
+ Array.prototype.concat.call(obj, obj2, arr); |
+ }, TypeError); |
+})(); |
+ |
+ |
(function testConcatHoleyArray() { |
"use strict"; |
var arr = []; |