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

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: Change copyright year to 2014 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
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 assertEquals(1, constructor.prototype.forEach.length);
20
21 var a = new constructor(2);
wingo 2014/09/23 18:11:25 tests needed that typed array foreach methods don'
22 a[0] = 0;
23 a[1] = 1;
24
25 var count = 0;
26 a.forEach(function (n) { count++; });
27 assertEquals(2, count);
28
29 // Use specified object as this object when calling the function.
30 var o = { value: 42 };
31 var result = [];
32 a.forEach(function (n, index, array) { result.push(this.value); }, o);
33 assertArrayEquals([42, 42], result);
34
35 // Modify the original array.
36 count = 0;
37 a.forEach(function (n, index, array) { array[index] = n + 1; count++ });
38 assertEquals(2, count);
39 assertArrayEquals([1, 2], a);
40 }
41
42 for (i = 0; i < typedArrayConstructors.length; i++) {
43 TestTypedArrayForEach(typedArrayConstructors[i]);
44 }
OLDNEW
« src/harmony-typedarray.js ('K') | « src/harmony-typedarray.js ('k') | tools/gyp/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698