OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 function test(f, expected, type) { |
| 6 try { |
| 7 f(); |
| 8 assertUnreachable(); |
| 9 } catch (e) { |
| 10 assertInstanceof(e, type); |
| 11 assertEquals(expected, e.message); |
| 12 } |
| 13 } |
| 14 |
| 15 // === Error === |
| 16 |
| 17 // kCyclicProto |
| 18 test(function() { |
| 19 var o = {}; |
| 20 o.__proto__ = o; |
| 21 }, "Cyclic __proto__ value", Error); |
| 22 |
| 23 |
| 24 // === TypeError === |
| 25 |
| 26 // kGeneratorRunning |
| 27 test(function() { |
| 28 var iter; |
| 29 function* generator() { yield iter.next(); } |
| 30 var iter = generator(); |
| 31 iter.next(); |
| 32 }, "Generator is already running", TypeError); |
| 33 |
| 34 // kCalledNonCallable |
| 35 test(function() { |
| 36 [].forEach(1); |
| 37 }, "1 is not a function", TypeError); |
| 38 |
| 39 // kIncompatibleMethodReceiver |
| 40 test(function() { |
| 41 RegExp.prototype.compile.call(RegExp.prototype); |
| 42 }, "Method RegExp.prototype.compile called on incompatible receiver " + |
| 43 "[object RegExp]", TypeError); |
| 44 |
| 45 // kPropertyNotFunction |
| 46 test(function() { |
| 47 Set.prototype.add = 0; |
| 48 new Set(1); |
| 49 }, "Property 'add' of object #<Set> is not a function", TypeError); |
| 50 |
| 51 // kWithExpression |
| 52 test(function() { |
| 53 with (null) {} |
| 54 }, "null has no properties", TypeError); |
OLD | NEW |