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

Side by Side Diff: test/mjsunit/es6/typedarray-every.js

Issue 2775203002: [builtins] Implement %TypedArray%.prototype.{some,every} in the CSA (Closed)
Patch Set: addressed comments Created 3 years, 8 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/code-stub-assembler.cc ('k') | no next file » | 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: --allow-natives-syntax 5 // Flags: --allow-natives-syntax
6 6
7 var typedArrayConstructors = [ 7 var typedArrayConstructors = [
8 Uint8Array, 8 Uint8Array,
9 Int8Array, 9 Int8Array,
10 Uint16Array, 10 Uint16Array,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 if (count > 0) %ArrayBufferNeuter(array.buffer); 91 if (count > 0) %ArrayBufferNeuter(array.buffer);
92 array[index] = n + 1; 92 array[index] = n + 1;
93 count++; 93 count++;
94 return count > 1 ? array[index] === undefined : true; 94 return count > 1 ? array[index] === undefined : true;
95 }); 95 });
96 assertEquals(2, count); 96 assertEquals(2, count);
97 assertEquals(true, result); 97 assertEquals(true, result);
98 CheckTypedArrayIsNeutered(a); 98 CheckTypedArrayIsNeutered(a);
99 assertEquals(undefined, a[0]); 99 assertEquals(undefined, a[0]);
100 100
101 // Calling array.buffer midway can change the backing store.
102 a = new constructor(5);
103 a[0] = 42;
104 result = a.every(function (n, index, array) {
105 assertSame(a, array);
106 if (index == 2) {
107 (new constructor(array.buffer))[(index + 1) % 5] = 42;
108 } else {
109 a[(index+1)%5] = 42
110 }
111 return n == 42;
112 });
113 assertEquals(true, result);
114
101 // The method must work for typed arrays created from ArrayBuffer. 115 // The method must work for typed arrays created from ArrayBuffer.
102 // The length of the ArrayBuffer is chosen so it is a multiple of 116 // The length of the ArrayBuffer is chosen so it is a multiple of
103 // all lengths of the typed array items. 117 // all lengths of the typed array items.
104 a = new constructor(new ArrayBuffer(64)); 118 a = new constructor(new ArrayBuffer(64));
105 count = 0; 119 count = 0;
106 result = a.every(function (n) { return n == 0; }); 120 result = a.every(function (n) { return n == 0; });
107 assertEquals(result, true); 121 assertEquals(result, true);
108 122
109 // Externalizing the array mid-way accessing the .buffer property 123 // Externalizing the array mid-way accessing the .buffer property
110 // should work. 124 // should work.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 assertEquals(a.every(function(elt) { x += elt; return true; }), true); 157 assertEquals(a.every(function(elt) { x += elt; return true; }), true);
144 assertEquals(x, 3); 158 assertEquals(x, 3);
145 assertEquals(Array.prototype.every.call(a, 159 assertEquals(Array.prototype.every.call(a,
146 function(elt) { x += elt; return true; }), true); 160 function(elt) { x += elt; return true; }), true);
147 assertEquals(x, 4); 161 assertEquals(x, 4);
148 } 162 }
149 163
150 for (i = 0; i < typedArrayConstructors.length; i++) { 164 for (i = 0; i < typedArrayConstructors.length; i++) {
151 TestTypedArrayForEach(typedArrayConstructors[i]); 165 TestTypedArrayForEach(typedArrayConstructors[i]);
152 } 166 }
OLDNEW
« no previous file with comments | « src/code-stub-assembler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698