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 // Flags: --harmony-tostring --harmony-proxies | 5 // Flags: --harmony-tostring --harmony-proxies |
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 Object.prototype.toString.call(obj)); | 37 Object.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 Object.prototype.toString.call(obj); | 45 Object.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 Object.prototype.toString.call(obj)); | 54 Object.prototype.toString.call(obj)); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 assertTag("Function", new Proxy(() => 42, {get() {return 666}})); | 152 assertTag("Function", new Proxy(() => 42, {get() {return 666}})); |
153 | 153 |
154 revocable = Proxy.revocable([], {}); | 154 revocable = Proxy.revocable([], {}); |
155 revocable.revoke(); | 155 revocable.revoke(); |
156 assertThrows(() => Object.prototype.toString.call(revocable.proxy), TypeError); | 156 assertThrows(() => Object.prototype.toString.call(revocable.proxy), TypeError); |
157 | 157 |
158 handler = {}; | 158 handler = {}; |
159 revocable = Proxy.revocable([], handler); | 159 revocable = Proxy.revocable([], handler); |
160 handler.get = () => revocable.revoke(); | 160 handler.get = () => revocable.revoke(); |
161 assertThrows(() => Object.prototype.toString.call(revocable.proxy), TypeError); | 161 assertThrows(() => Object.prototype.toString.call(revocable.proxy), TypeError); |
OLD | NEW |