| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Test that type checks occur on native methods. | 5 // Test that type checks occur on native methods. |
| 6 | 6 |
| 7 class A native "*A" { | 7 class A native "*A" { |
| 8 int foo(int x) native; | 8 int foo(int x) native; |
| 9 int cmp(A other) native; | 9 int cmp(A other) native; |
| 10 } | 10 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 B.prototype.cmp = function (x) { return 1; }; | 27 B.prototype.cmp = function (x) { return 1; }; |
| 28 | 28 |
| 29 makeA = function(){return new A;}; | 29 makeA = function(){return new A;}; |
| 30 makeB = function(){return new B;}; | 30 makeB = function(){return new B;}; |
| 31 """; | 31 """; |
| 32 | 32 |
| 33 expectThrows(action()) { | 33 expectThrows(action()) { |
| 34 bool threw = false; | 34 bool threw = false; |
| 35 try { | 35 try { |
| 36 action(); | 36 action(); |
| 37 } catch (var e) { | 37 } catch (e) { |
| 38 threw = true; | 38 threw = true; |
| 39 } | 39 } |
| 40 Expect.isTrue(threw); | 40 Expect.isTrue(threw); |
| 41 } | 41 } |
| 42 | 42 |
| 43 checkedModeTest() { | 43 checkedModeTest() { |
| 44 var things = [makeA(), makeB()]; | 44 var things = [makeA(), makeB()]; |
| 45 var a = things[0]; | 45 var a = things[0]; |
| 46 var b = things[1]; | 46 var b = things[1]; |
| 47 | 47 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 Expect.equals(1, bb.cmp(5)); | 116 Expect.equals(1, bb.cmp(5)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool isCheckedMode() { | 119 bool isCheckedMode() { |
| 120 var stuff = [1, 'string']; | 120 var stuff = [1, 'string']; |
| 121 var a = stuff[0]; | 121 var a = stuff[0]; |
| 122 // Checked-mode detection. | 122 // Checked-mode detection. |
| 123 try { | 123 try { |
| 124 String s = a; | 124 String s = a; |
| 125 return false; | 125 return false; |
| 126 } catch (var e) { } | 126 } catch (e) { |
| 127 // Ignore. |
| 128 } |
| 127 return true; | 129 return true; |
| 128 } | 130 } |
| 129 | 131 |
| 130 main() { | 132 main() { |
| 131 setup(); | 133 setup(); |
| 132 | 134 |
| 133 if (isCheckedMode()) { | 135 if (isCheckedMode()) { |
| 134 checkedModeTest(); | 136 checkedModeTest(); |
| 135 } else { | 137 } else { |
| 136 uncheckedModeTest(); | 138 uncheckedModeTest(); |
| 137 } | 139 } |
| 138 } | 140 } |
| OLD | NEW |