| 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 // Dart test program for testing throw statement | 4 // Dart test program for testing throw statement |
| 5 | 5 |
| 6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
| 7 | 7 |
| 8 class MyException { | 8 class MyException { |
| 9 const MyException(String message) : message_ = message; | 9 const MyException(String message) : message_ = message; |
| 10 final String message_; | 10 final String message_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 return func4(); | 48 return func4(); |
| 49 } | 49 } |
| 50 static int func4() { | 50 static int func4() { |
| 51 var i = 0; | 51 var i = 0; |
| 52 try { | 52 try { |
| 53 i = 10; | 53 i = 10; |
| 54 func5(); | 54 func5(); |
| 55 } on ArgumentError catch (e, s) { | 55 } on ArgumentError catch (e, s) { |
| 56 i = 200; | 56 i = 200; |
| 57 Expect.isNotNull(e.stackTrace, "Errors need a stackTrace on throw"); | 57 Expect.isNotNull(e.stackTrace, "Errors need a stackTrace on throw"); |
| 58 Expect.isFalse(identical(e.stackTrace, s)); | |
| 59 Expect.equals(e.stackTrace.toString(), s.toString()); | 58 Expect.equals(e.stackTrace.toString(), s.toString()); |
| 60 } | 59 } |
| 61 return i; | 60 return i; |
| 62 } | 61 } |
| 63 static List func5() { | 62 static List func5() { |
| 64 // Throw an Error. | 63 // Throw an Error. |
| 65 throw new ArgumentError("ArgumentError in func5"); | 64 throw new ArgumentError("ArgumentError in func5"); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 | 67 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 static testMain() { | 102 static testMain() { |
| 104 Expect.equals(100, Helper1.func1()); | 103 Expect.equals(100, Helper1.func1()); |
| 105 Expect.equals(200, Helper2.func1()); | 104 Expect.equals(200, Helper2.func1()); |
| 106 Expect.equals(300, Helper3.func1()); | 105 Expect.equals(300, Helper3.func1()); |
| 107 } | 106 } |
| 108 } | 107 } |
| 109 | 108 |
| 110 main() { | 109 main() { |
| 111 ErrorStackTraceTest.testMain(); | 110 ErrorStackTraceTest.testMain(); |
| 112 } | 111 } |
| OLD | NEW |