Chromium Code Reviews| 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 // This must never be reached: | |
| 52 assertEquals(true, false); | |
|
arv (Not doing code reviews)
2014/12/09 21:59:21
assertUnreachable()
| |
| 53 } catch (exception) { | |
| 54 assertTrue(exception instanceof TypeError); | |
| 55 assertEquals('Function.prototype.toMethod: home object null ' + | |
| 56 'is not an object', exception.message); | |
|
arv (Not doing code reviews)
2014/12/09 21:59:20
+2 indent
| |
| 57 } | |
| 58 try { | |
| 59 Function.prototype.toMethod.call(42, null); | |
| 60 // This must never be reached: | |
| 61 assertEquals(true, false); | |
| 62 } catch (exception) { | |
| 63 assertTrue(exception instanceof TypeError); | |
| 64 assertEquals('Function.prototype.toMethod: home object null ' + | |
| 65 'is not an object', exception.message); | |
| 66 } | |
| 67 try { | |
| 68 Function.prototype.toMethod.call(42, {}); | |
| 69 // This must never be reached: | |
| 70 assertEquals(true, false); | |
| 71 } catch (exception) { | |
| 72 assertTrue(exception instanceof TypeError); | |
| 73 assertEquals('Function.prototype.toMethod was called on 42, which is a ' + | |
| 74 'number and not a function', exception.message); | |
| 75 } | |
|
mathiasb
2014/12/09 21:59:11
I’d love to use `assertThrows` here, but its optio
| |
| 49 }()); | 76 }()); |
| 50 | 77 |
| 51 | 78 |
| 52 (function TestPrototypeChain() { | 79 (function TestPrototypeChain() { |
| 53 var o = {}; | 80 var o = {}; |
| 54 var o1 = {}; | 81 var o1 = {}; |
| 55 function f() { } | 82 function f() { } |
| 56 | 83 |
| 57 function g() { } | 84 function g() { } |
| 58 | 85 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 assertEquals("abc", g(o1)); | 133 assertEquals("abc", g(o1)); |
| 107 } ()); | 134 } ()); |
| 108 | 135 |
| 109 (function TestExtensibility() { | 136 (function TestExtensibility() { |
| 110 function f() {} | 137 function f() {} |
| 111 Object.preventExtensions(f); | 138 Object.preventExtensions(f); |
| 112 assertFalse(Object.isExtensible(f)); | 139 assertFalse(Object.isExtensible(f)); |
| 113 var m = f.toMethod({}); | 140 var m = f.toMethod({}); |
| 114 assertTrue(Object.isExtensible(m)); | 141 assertTrue(Object.isExtensible(m)); |
| 115 }()); | 142 }()); |
| OLD | NEW |