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