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

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

Issue 2763473002: [typedarrays] Move %TypedArray%.prototype.slice to C++ (Closed)
Patch Set: rebase 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
« no previous file with comments | « 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..8f94f156afa51c48ca7c50de8f298495ecce4eaa 100644
--- a/test/mjsunit/es6/typedarray-slice.js
+++ b/test/mjsunit/es6/typedarray-slice.js
@@ -68,4 +68,28 @@ for (var constructor of typedArrayConstructors) {
assertEquals(2, slice[0]);
assertEquals(3, slice[1]);
assertTrue(slice instanceof constructor);
+
+ // Check that the species array must be a typed array
+ class MyTypedArray extends constructor {
+ static get[Symbol.species]() {
+ return Array;
+ }
+ }
+ var arr = new MyTypedArray([-1.0, 0, 1.1, 255, 256]);
+ assertThrows(() => arr.slice(), TypeError);
+}
+
+// Check that the result array is properly created by checking species
+for (var constructor1 of typedArrayConstructors) {
+ for (var constructor2 of typedArrayConstructors) {
+ class MyTypedArray2 extends constructor1 {
+ static get[Symbol.species]() {
+ return constructor2;
+ }
+ }
+ var arr = new MyTypedArray2([-1.0, 0, 1.1, 255, 256]);
+ var arr2 = new constructor1([-1.0, 0, 1.1, 255, 256]);
+ assertEquals(new constructor2(arr2), arr.slice(),
+ constructor1.name + ' -> ' + constructor2.name);
+ }
}
« no previous file with comments | « src/js/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698