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

Unified Diff: test/mjsunit/es6/typedarray-set-byteoffset-internal.js

Issue 2761673003: [typedarrays] Use internal byteOffset in TypedArray.prototype.set (Closed)
Patch Set: 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-set-byteoffset-internal.js
diff --git a/test/mjsunit/es6/typedarray-set-byteoffset-internal.js b/test/mjsunit/es6/typedarray-set-byteoffset-internal.js
new file mode 100644
index 0000000000000000000000000000000000000000..1fcc0ce35a58eaa01bfd64abf76702807d31ef60
--- /dev/null
+++ b/test/mjsunit/es6/typedarray-set-byteoffset-internal.js
@@ -0,0 +1,35 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var typedArrayConstructors = [
+ Uint8Array,
+ Int8Array,
+ Uint16Array,
+ Int16Array,
+ Uint32Array,
+ Int32Array,
+ Uint8ClampedArray,
+ Float32Array,
+ Float64Array
+];
+
+var descriptor = { get: function() { throw new Error("accessed byteOffset"); } };
+
+for (var constructor of typedArrayConstructors) {
+ var differentConstructor =
+ constructor === Uint8Array ? Int8Array : Uint8Array;
+ var target = new constructor(16);
+ Object.defineProperty(target, "byteOffset", descriptor);
+
+ var sameBuffer = new differentConstructor(target.buffer, 0, 2);
+ Object.defineProperty(sameBuffer, "byteOffset", descriptor);
+ target.set(sameBuffer);
+
+ var differentBuffer = new differentConstructor(16);
+ Object.defineProperty(differentBuffer, "byteOffset", descriptor);
+ target.set(differentBuffer);
+
+ var array = [0, 1, 2];
+ target.set(array);
+}
Dan Ehrenberg 2017/04/03 09:39:24 These tests are great. Nit: Please cross-reference
Choongwoo Han 2017/04/03 11:43:38 I cannot fully understand the process of the test2
« 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