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 | 5 |
6 var funcs = [ | 6 var funcs = [ |
7 | 7 |
8 // https://code.google.com/p/v8/issues/detail?id=4002 | 8 // https://code.google.com/p/v8/issues/detail?id=4002 |
9 // Error, | 9 // Error, |
10 // EvalError, | 10 // EvalError, |
11 // RangeError, | 11 // RangeError, |
12 // ReferenceError, | 12 // ReferenceError, |
13 // SyntaxError, | 13 // SyntaxError, |
14 // TypeError, | 14 // TypeError, |
15 // URIError, | 15 // URIError, |
16 | 16 |
17 // https://code.google.com/p/v8/issues/detail?id=4003 | 17 // https://code.google.com/p/v8/issues/detail?id=4003 |
18 // RegExp, | 18 // RegExp, |
19 | 19 |
20 // https://code.google.com/p/v8/issues/detail?id=4004 | 20 // https://code.google.com/p/v8/issues/detail?id=4004 |
21 // Date, | 21 // Date, |
22 | 22 |
23 // https://code.google.com/p/v8/issues/detail?id=4006 | 23 // https://code.google.com/p/v8/issues/detail?id=4006 |
24 // String, | 24 // String, |
25 | 25 |
26 ArrayBuffer, | |
27 Boolean, | 26 Boolean, |
28 DataView, | |
29 Float32Array, | 27 Float32Array, |
30 Float64Array, | 28 Float64Array, |
31 Int16Array, | 29 Int16Array, |
32 Int32Array, | 30 Int32Array, |
33 Int8Array, | 31 Int8Array, |
34 Map, | |
35 Number, | 32 Number, |
36 Object, | 33 Object, |
37 Promise, | |
38 // Proxy, | |
39 Set, | |
40 Symbol, | |
41 Uint16Array, | 34 Uint16Array, |
42 Uint32Array, | 35 Uint32Array, |
43 Uint8Array, | 36 Uint8Array, |
44 Uint8ClampedArray, | 37 Uint8ClampedArray |
45 WeakMap, | |
46 WeakSet, | |
47 ]; | 38 ]; |
48 | 39 |
49 for (var fun of funcs) { | 40 for (var fun of funcs) { |
50 var p = fun.prototype; | 41 var p = fun.prototype; |
51 assertEquals('[object Object]', Object.prototype.toString.call(p)); | 42 assertEquals('[object Object]', Object.prototype.toString.call(p)); |
52 } | 43 } |
53 | 44 |
54 | 45 |
55 // These still have special prototypes for legacy reason. | 46 // These still have special prototypes for legacy reason. |
56 var funcs = [ | 47 var funcs = [ |
57 Array, | 48 Array, |
58 Function, | 49 Function, |
59 ]; | 50 ]; |
60 | 51 |
61 for (var fun of funcs) { | 52 for (var fun of funcs) { |
62 var p = fun.prototype; | 53 var p = fun.prototype; |
63 assertEquals('[object ' + fun.name + ']', Object.prototype.toString.call(p)); | 54 assertEquals('[object ' + fun.name + ']', Object.prototype.toString.call(p)); |
64 } | 55 } |
56 | |
57 | |
58 // @@toStringTag alters the result of O.p.toString() | |
59 // %TypedArray% [ @@toStringTag ] is an accessor which returns undefined if | |
arv (Not doing code reviews)
2015/04/09 13:41:22
Do we have a bug then? Float32Array etc above shou
caitp (gmail)
2015/04/09 14:10:22
They have @@toStringTag --- it's a getter which is
| |
60 // receiver is not a %TypedArray%, and thus does not appear in this list. | |
61 var funcs = [ | |
62 ArrayBuffer, | |
63 DataView, | |
64 Map, | |
65 Promise, | |
66 Set, | |
67 Symbol, | |
68 WeakMap, | |
69 WeakSet | |
70 ]; | |
71 | |
72 for (var fun of funcs) { | |
73 var p = fun.prototype; | |
74 var name = p[Symbol.toStringTag]; | |
75 assertEquals(name, fun.name); | |
76 assertEquals(`[object ${name}]`, Object.prototype.toString.call(p)); | |
arv (Not doing code reviews)
2015/04/09 13:41:22
update line 54 for consistency?
caitp (gmail)
2015/04/09 14:10:22
Acknowledged.
| |
77 } | |
OLD | NEW |