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

Side by Side Diff: test/mjsunit/harmony/typedarrays-foreach.js

Issue 583723002: Implement .forEach() on typed arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/harmony-typedarray.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-typedarrays
6
7 var typedArrayConstructors = [
8 Uint8Array,
9 Int8Array,
10 Uint16Array,
11 Int16Array,
12 Uint32Array,
13 Int32Array,
14 Uint8ClampedArray,
15 Float32Array,
16 Float64Array];
17
18 function TestTypedArrayForEach(constructor) {
19 var a = new constructor(2);
20 a[0] = 0;
21 a[1] = 1;
22
23 var count = 0;
24 a.forEach(function (n) { count++; });
25 assertEquals(2, count);
26
27 // Use specified object as this object when calling the function.
28 var o = { value: 42 };
29 var result = [];
30 a.forEach(function (n, index, array) { result.push(this.value); }, o);
31 assertArrayEquals([42, 42], result);
32
33 // Modify the original array.
34 count = 0;
35 a.forEach(function (n, index, array) { array[index] = n + 1; count++ });
36 assertEquals(2, count);
37 assertArrayEquals([1, 2], a);
38
39 // Respect holes
aperez 2014/09/18 18:18:39 I have to remove this leftover comment, typed arra
40 }
41
42 for (i = 0; i < typedArrayConstructors.length; i++) {
43 TestTypedArrayForEach(typedArrayConstructors[i]);
44 }
OLDNEW
« no previous file with comments | « src/harmony-typedarray.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698