| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 void argument() { | 7 void argument() { |
| 8 throw new ArgumentError(499); | 8 throw new ArgumentError(499); |
| 9 } | 9 } |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 void state() { | 50 void state() { |
| 51 return [1, 2].single; | 51 return [1, 2].single; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void type() { | 54 void type() { |
| 55 return 1 + "string"; | 55 return 1 + "string"; |
| 56 } | 56 } |
| 57 | 57 |
| 58 main() { | 58 main() { |
| 59 List<Function> errorFunctions = [ | 59 List<Function> errorFunctions = [ |
| 60 argument, noSuchMethod, nullThrown, range, fallThrough, | 60 argument, |
| 61 abstractClassInstantiation, unsupported, unimplemented, state, | 61 noSuchMethod, |
| 62 type ]; | 62 nullThrown, |
| 63 range, |
| 64 fallThrough, |
| 65 abstractClassInstantiation, |
| 66 unsupported, |
| 67 unimplemented, |
| 68 state, |
| 69 type |
| 70 ]; |
| 63 | 71 |
| 64 for (var f in errorFunctions) { | 72 for (var f in errorFunctions) { |
| 65 bool hasThrown = false; | 73 bool hasThrown = false; |
| 66 try { | 74 try { |
| 67 f(); | 75 f(); |
| 68 } catch(e) { | 76 } catch (e) { |
| 69 hasThrown = true; | 77 hasThrown = true; |
| 70 Expect.isTrue(e.stackTrace is StackTrace, | 78 Expect.isTrue( |
| 71 "$e doesn't have a non-null stack trace"); | 79 e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace"); |
| 72 } | 80 } |
| 73 Expect.isTrue(hasThrown); | 81 Expect.isTrue(hasThrown); |
| 74 } | 82 } |
| 75 } | 83 } |
| OLD | NEW |