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 // Flags: --harmony-tostring | 5 // Flags: --harmony-tostring |
6 | 6 |
7 var global = this; | 7 var global = this; |
8 | 8 |
9 var funs = { | 9 var funs = { |
10 Object: [ Object ], | 10 Object: [ Object ], |
(...skipping 23 matching lines...) Expand all Loading... |
34 var obj = {}; | 34 var obj = {}; |
35 obj[Symbol.toStringTag] = className; | 35 obj[Symbol.toStringTag] = className; |
36 assertEquals("[object " + className + "]", | 36 assertEquals("[object " + className + "]", |
37 Array.prototype.toString.call(obj)); | 37 Array.prototype.toString.call(obj)); |
38 | 38 |
39 // Getter throws | 39 // Getter throws |
40 obj = {}; | 40 obj = {}; |
41 Object.defineProperty(obj, Symbol.toStringTag, { | 41 Object.defineProperty(obj, Symbol.toStringTag, { |
42 get: function() { throw className; } | 42 get: function() { throw className; } |
43 }); | 43 }); |
44 assertThrows(function() { | 44 assertThrowsEquals(function() { |
45 Array.prototype.toString.call(obj); | 45 Array.prototype.toString.call(obj); |
46 }, className); | 46 }, className); |
47 | 47 |
48 // Getter does not throw | 48 // Getter does not throw |
49 obj = {}; | 49 obj = {}; |
50 Object.defineProperty(obj, Symbol.toStringTag, { | 50 Object.defineProperty(obj, Symbol.toStringTag, { |
51 get: function() { return className; } | 51 get: function() { return className; } |
52 }); | 52 }); |
53 assertEquals("[object " + className + "]", | 53 assertEquals("[object " + className + "]", |
54 Array.prototype.toString.call(obj)); | 54 Array.prototype.toString.call(obj)); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 assertEquals(",,3", [,,3].toString()); | 148 assertEquals(",,3", [,,3].toString()); |
149 } | 149 } |
150 testArrayToStringBasic(); | 150 testArrayToStringBasic(); |
151 | 151 |
152 | 152 |
153 function testArrayToStringObjectWithCallableJoin() { | 153 function testArrayToStringObjectWithCallableJoin() { |
154 var obj = { join: function() { return "CallableJoin"; } }; | 154 var obj = { join: function() { return "CallableJoin"; } }; |
155 assertEquals("CallableJoin", Array.prototype.toString.call(obj)); | 155 assertEquals("CallableJoin", Array.prototype.toString.call(obj)); |
156 } | 156 } |
157 testArrayToStringObjectWithCallableJoin(); | 157 testArrayToStringObjectWithCallableJoin(); |
OLD | NEW |