OLD | NEW |
| (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-iteration | |
6 | |
7 | |
8 var constructors = [Uint8Array, Int8Array, | |
9 Uint16Array, Int16Array, | |
10 Uint32Array, Int32Array, | |
11 Float32Array, Float64Array, | |
12 Uint8ClampedArray]; | |
13 | |
14 function TestTypedArrayPrototype(constructor) { | |
15 assertTrue(constructor.prototype.hasOwnProperty('entries')); | |
16 assertTrue(constructor.prototype.hasOwnProperty('values')); | |
17 assertTrue(constructor.prototype.hasOwnProperty('keys')); | |
18 assertTrue(constructor.prototype.hasOwnProperty(Symbol.iterator)); | |
19 | |
20 assertFalse(constructor.prototype.propertyIsEnumerable('entries')); | |
21 assertFalse(constructor.prototype.propertyIsEnumerable('values')); | |
22 assertFalse(constructor.prototype.propertyIsEnumerable('keys')); | |
23 assertFalse(constructor.prototype.propertyIsEnumerable(Symbol.iterator)); | |
24 | |
25 assertEquals(Array.prototype.entries, constructor.prototype.entries); | |
26 assertEquals(Array.prototype.values, constructor.prototype.values); | |
27 assertEquals(Array.prototype.keys, constructor.prototype.keys); | |
28 assertEquals(Array.prototype.values, constructor.prototype[Symbol.iterator]); | |
29 } | |
30 constructors.forEach(TestTypedArrayPrototype); | |
31 | |
32 | |
33 function TestTypedArrayValues(constructor) { | |
34 var array = [1, 2, 3]; | |
35 var i = 0; | |
36 for (var value of new constructor(array)) { | |
37 assertEquals(array[i++], value); | |
38 } | |
39 assertEquals(i, array.length); | |
40 } | |
41 constructors.forEach(TestTypedArrayValues); | |
OLD | NEW |