Index: test/mjsunit/es6/typedarray-slice.js |
diff --git a/test/mjsunit/es6/typedarray-slice.js b/test/mjsunit/es6/typedarray-slice.js |
index ddd021a8fa9d9e30bafbbafd3b92b214acaf3f69..621bd48a9fbc8ab2cdc0ddfed2cfe8c74518caf3 100644 |
--- a/test/mjsunit/es6/typedarray-slice.js |
+++ b/test/mjsunit/es6/typedarray-slice.js |
@@ -68,4 +68,21 @@ for (var constructor of typedArrayConstructors) { |
assertEquals(2, slice[0]); |
assertEquals(3, slice[1]); |
assertTrue(slice instanceof constructor); |
+ |
+ // Check that the result array is properly created by checking species |
Camillo Bruni
2017/03/20 13:37:25
Could you extend this and add specific tests with
Choongwoo Han
2017/03/21 12:39:03
Done.
|
+ class MyFloat64Array extends Float64Array { |
+ static get[Symbol.species]() { |
+ return constructor; |
+ } |
+ } |
+ var arr = new MyFloat64Array([-1.0, 0, 255, 256]); |
+ assertEquals(new constructor([-1.0, 0, 255, 256]), arr.slice()); |
+ |
+ class MyTypedArray extends constructor { |
+ static get[Symbol.species]() { |
+ return Array; |
+ } |
+ } |
+ var arr = new MyTypedArray([-1.0, 0, 255, 256]); |
+ assertThrows(() => arr.slice(), TypeError); |
} |