| 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-classes --allow-natives-syntax | 5 // Flags: --harmony-classes --allow-natives-syntax |
| 6 | 6 |
| 7 | 7 |
| 8 (function TestSingleClass() { | 8 (function TestSingleClass() { |
| 9 function f(x) { | 9 function f(x) { |
| 10 var a = [0, 1, 2] | 10 var a = [0, 1, 2] |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 assertEquals(5, q(1)); | 39 assertEquals(5, q(1)); |
| 40 }()); | 40 }()); |
| 41 | 41 |
| 42 | 42 |
| 43 (function TestErrorCases() { | 43 (function TestErrorCases() { |
| 44 var sFun = Function.prototype.toMethod; | 44 var sFun = Function.prototype.toMethod; |
| 45 assertThrows(function() { sFun.call({}); }, TypeError); | 45 assertThrows(function() { sFun.call({}); }, TypeError); |
| 46 assertThrows(function() { sFun.call({}, {}); }, TypeError); | 46 assertThrows(function() { sFun.call({}, {}); }, TypeError); |
| 47 function f(){}; | 47 function f(){}; |
| 48 assertThrows(function() { f.toMethod(1); }, TypeError); | 48 assertThrows(function() { f.toMethod(1); }, TypeError); |
| 49 try { |
| 50 Function.prototype.toMethod.call(null, null); |
| 51 assertUnreachable(); |
| 52 } catch (exception) { |
| 53 assertTrue(exception instanceof TypeError); |
| 54 assertEquals('Function.prototype.toMethod: home object null ' + |
| 55 'is not an object', exception.message); |
| 56 } |
| 57 try { |
| 58 Function.prototype.toMethod.call(42, null); |
| 59 assertUnreachable(); |
| 60 } catch (exception) { |
| 61 assertTrue(exception instanceof TypeError); |
| 62 assertEquals('Function.prototype.toMethod: home object null ' + |
| 63 'is not an object', exception.message); |
| 64 } |
| 65 try { |
| 66 Function.prototype.toMethod.call(42, {}); |
| 67 assertUnreachable(); |
| 68 } catch (exception) { |
| 69 assertTrue(exception instanceof TypeError); |
| 70 assertEquals('Function.prototype.toMethod was called on 42, which is a ' + |
| 71 'number and not a function', exception.message); |
| 72 } |
| 49 }()); | 73 }()); |
| 50 | 74 |
| 51 | 75 |
| 52 (function TestPrototypeChain() { | 76 (function TestPrototypeChain() { |
| 53 var o = {}; | 77 var o = {}; |
| 54 var o1 = {}; | 78 var o1 = {}; |
| 55 function f() { } | 79 function f() { } |
| 56 | 80 |
| 57 function g() { } | 81 function g() { } |
| 58 | 82 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 assertEquals("abc", g(o1)); | 130 assertEquals("abc", g(o1)); |
| 107 } ()); | 131 } ()); |
| 108 | 132 |
| 109 (function TestExtensibility() { | 133 (function TestExtensibility() { |
| 110 function f() {} | 134 function f() {} |
| 111 Object.preventExtensions(f); | 135 Object.preventExtensions(f); |
| 112 assertFalse(Object.isExtensible(f)); | 136 assertFalse(Object.isExtensible(f)); |
| 113 var m = f.toMethod({}); | 137 var m = f.toMethod({}); |
| 114 assertTrue(Object.isExtensible(m)); | 138 assertTrue(Object.isExtensible(m)); |
| 115 }()); | 139 }()); |
| OLD | NEW |