OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 // Test that the methods for different TypedArray types have the same | 5 // Test that the methods for different TypedArray types have the same |
6 // identity. | 6 // identity. |
7 | 7 |
8 'use strict'; | 8 'use strict'; |
9 | 9 |
10 let typedArrayConstructors = [ | 10 let typedArrayConstructors = [ |
(...skipping 10 matching lines...) Expand all Loading... |
21 let TypedArray = Uint8Array.__proto__; | 21 let TypedArray = Uint8Array.__proto__; |
22 let TypedArrayPrototype = TypedArray.prototype; | 22 let TypedArrayPrototype = TypedArray.prototype; |
23 | 23 |
24 assertEquals(TypedArray.__proto__, Function.prototype); | 24 assertEquals(TypedArray.__proto__, Function.prototype); |
25 assertEquals(TypedArrayPrototype.__proto__, Object.prototype); | 25 assertEquals(TypedArrayPrototype.__proto__, Object.prototype); |
26 | 26 |
27 // There are extra own class properties due to it simply being a function | 27 // There are extra own class properties due to it simply being a function |
28 let classProperties = new Set([ | 28 let classProperties = new Set([ |
29 "length", "name", "arguments", "caller", "prototype", "BYTES_PER_ELEMENT" | 29 "length", "name", "arguments", "caller", "prototype", "BYTES_PER_ELEMENT" |
30 ]); | 30 ]); |
31 let instanceProperties = new Set([ | 31 let instanceProperties = new Set(["BYTES_PER_ELEMENT", "constructor", "prototype
"]); |
32 "BYTES_PER_ELEMENT", "constructor", "prototype", | |
33 // length is also an instance property as a temporary workaround to | |
34 // BUG(chromium:579905). TODO(littledan): remove the workaround | |
35 "length" | |
36 ]); | |
37 | 32 |
38 function functionProperties(object) { | 33 function functionProperties(object) { |
39 return Object.getOwnPropertyNames(object).filter(function(name) { | 34 return Object.getOwnPropertyNames(object).filter(function(name) { |
40 return typeof Object.getOwnPropertyDescriptor(object, name).value | 35 return typeof Object.getOwnPropertyDescriptor(object, name).value |
41 == "function" && name != 'constructor'; | 36 == "function" |
| 37 && name != 'constructor' && name != 'subarray'; |
42 }); | 38 }); |
43 } | 39 } |
44 | 40 |
45 let typedArrayMethods = functionProperties(Uint8Array.prototype); | 41 let typedArrayMethods = functionProperties(Uint8Array.prototype); |
46 let typedArrayClassMethods = functionProperties(Uint8Array); | 42 let typedArrayClassMethods = functionProperties(Uint8Array); |
47 | 43 |
48 for (let constructor of typedArrayConstructors) { | 44 for (let constructor of typedArrayConstructors) { |
49 for (let property of Object.getOwnPropertyNames(constructor.prototype)) { | 45 for (let property of Object.getOwnPropertyNames(constructor.prototype)) { |
50 assertTrue(instanceProperties.has(property), property); | 46 assertTrue(instanceProperties.has(property), property); |
51 } | 47 } |
(...skipping 13 matching lines...) Expand all Loading... |
65 assertFalse(desc.writable); | 61 assertFalse(desc.writable); |
66 assertFalse(desc.configurable); | 62 assertFalse(desc.configurable); |
67 assertFalse(desc.enumerable); | 63 assertFalse(desc.enumerable); |
68 | 64 |
69 for (let constructor of typedArrayConstructors) { | 65 for (let constructor of typedArrayConstructors) { |
70 let desc = Object.getOwnPropertyDescriptor(constructor, "prototype"); | 66 let desc = Object.getOwnPropertyDescriptor(constructor, "prototype"); |
71 assertFalse(desc.writable); | 67 assertFalse(desc.writable); |
72 assertFalse(desc.configurable); | 68 assertFalse(desc.configurable); |
73 assertFalse(desc.enumerable); | 69 assertFalse(desc.enumerable); |
74 } | 70 } |
OLD | NEW |