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

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

Issue 1133503003: Factor out core of Array.forEach and .every, for use in TypedArrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « src/harmony-typedarray.js ('k') | test/mjsunit/harmony/typedarrays-foreach.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Flags: --harmony-arrays --allow-natives-syntax 5 // Flags: --harmony-arrays --allow-natives-syntax
6 6
7 var typedArrayConstructors = [ 7 var typedArrayConstructors = [
8 Uint8Array, 8 Uint8Array,
9 Int8Array, 9 Int8Array,
10 Uint16Array, 10 Uint16Array,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 CheckWrapping(false, Boolean); 78 CheckWrapping(false, Boolean);
79 CheckWrapping("xxx", String); 79 CheckWrapping("xxx", String);
80 CheckWrapping(42, Number); 80 CheckWrapping(42, Number);
81 CheckWrapping(3.14, Number); 81 CheckWrapping(3.14, Number);
82 CheckWrapping({}, Object); 82 CheckWrapping({}, Object);
83 83
84 // Neutering the buffer backing the typed array mid-way should 84 // Neutering the buffer backing the typed array mid-way should
85 // still make .forEach() finish, and the array should keep being 85 // still make .forEach() finish, and the array should keep being
86 // empty after neutering it. 86 // empty after neutering it.
87 count = 0; 87 count = 0;
88 a = new constructor(2); 88 a = new constructor(3);
89 result = a.every(function (n, index, array) { 89 result = a.every(function (n, index, array) {
90 assertFalse(array[index] === undefined); // don't get here if neutered
90 if (count > 0) %ArrayBufferNeuter(array.buffer); 91 if (count > 0) %ArrayBufferNeuter(array.buffer);
91 array[index] = n + 1; 92 array[index] = n + 1;
92 count++; 93 count++;
93 return count > 1 ? array[index] === undefined : true; 94 return count > 1 ? array[index] === undefined : true;
94 }); 95 });
95 assertEquals(2, count); 96 assertEquals(2, count);
96 assertEquals(true, result); 97 assertEquals(true, result);
97 CheckTypedArrayIsNeutered(a); 98 CheckTypedArrayIsNeutered(a);
98 assertEquals(undefined, a[0]); 99 assertEquals(undefined, a[0]);
99 100
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 count = 0; 133 count = 0;
133 a = new typedArrayConstructors[i](4); 134 a = new typedArrayConstructors[i](4);
134 constructor.prototype.every.call(a, function (x) { count++; return true; }); 135 constructor.prototype.every.call(a, function (x) { count++; return true; });
135 assertEquals(a.length, count); 136 assertEquals(a.length, count);
136 } 137 }
137 } 138 }
138 139
139 for (i = 0; i < typedArrayConstructors.length; i++) { 140 for (i = 0; i < typedArrayConstructors.length; i++) {
140 TestTypedArrayForEach(typedArrayConstructors[i]); 141 TestTypedArrayForEach(typedArrayConstructors[i]);
141 } 142 }
OLDNEW
« no previous file with comments | « src/harmony-typedarray.js ('k') | test/mjsunit/harmony/typedarrays-foreach.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698