OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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-instanceof | |
6 | |
7 // Make sure it's an error if @@hasInstance isn't a function. | 5 // Make sure it's an error if @@hasInstance isn't a function. |
8 (function() { | 6 (function() { |
9 var F = {}; | 7 var F = {}; |
10 F[Symbol.hasInstance] = null; | 8 F[Symbol.hasInstance] = null; |
11 assertThrows(function() { 0 instanceof F; }, TypeError); | 9 assertThrows(function() { 0 instanceof F; }, TypeError); |
12 })(); | 10 })(); |
13 | 11 |
14 // Make sure the result is coerced to boolean. | 12 // Make sure the result is coerced to boolean. |
15 (function() { | 13 (function() { |
16 var F = {}; | 14 var F = {}; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 (function() { | 58 (function() { |
61 function F() {} | 59 function F() {} |
62 var counter = 0; | 60 var counter = 0; |
63 var proto = Object.getPrototypeOf(F); | 61 var proto = Object.getPrototypeOf(F); |
64 Object.setPrototypeOf(F, null); | 62 Object.setPrototypeOf(F, null); |
65 F[Symbol.hasInstance] = function(v) { ++counter; return true }; | 63 F[Symbol.hasInstance] = function(v) { ++counter; return true }; |
66 Object.setPrototypeOf(F, proto); | 64 Object.setPrototypeOf(F, proto); |
67 assertTrue(1 instanceof F); | 65 assertTrue(1 instanceof F); |
68 assertEquals(1, counter); | 66 assertEquals(1, counter); |
69 })(); | 67 })(); |
OLD | NEW |