Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Unified Diff: test/mjsunit/es6/typedarray-slice.js

Issue 2763473002: [typedarrays] Move %TypedArray%.prototype.slice to C++ (Closed)
Patch Set: Add tests Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/builtins/builtins-typedarray.cc ('K') | « src/js/typedarray.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« src/builtins/builtins-typedarray.cc ('K') | « src/js/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698