| 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 // 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_; |
| 11 } | 11 } |
| 12 | 12 |
| 13 class Helper { | 13 class Helper { |
| 14 static int f1(int i) { | 14 static int f1(int i) { |
| 15 try { | 15 try { |
| 16 i = func(); | 16 i = func(); |
| 17 i = 10; | 17 i = 10; |
| 18 } on MyException catch (exception, stacktrace) { | 18 } on MyException catch (exception, stacktrace) { |
| 19 i = 50; | 19 i = 50; |
| 20 print(exception.message_); | 20 print(exception.message_); |
| 21 Expect.equals((stacktrace != null), true); | 21 Expect.isNotNull(stacktrace); |
| 22 print(stacktrace); | 22 print(stacktrace); |
| 23 } | 23 } |
| 24 try { | 24 try { |
| 25 int j; | 25 int j; |
| 26 i = func1(); | 26 i = func1(); |
| 27 i = 200; | 27 i = 200; |
| 28 } on MyException catch (exception, stacktrace) { | 28 } on MyException catch (exception, stacktrace) { |
| 29 i = 50; | 29 i = 50; |
| 30 print(exception.message_); | 30 print(exception.message_); |
| 31 Expect.equals((stacktrace != null), true); | 31 Expect.isNotNull(stacktrace); |
| 32 print(stacktrace); | 32 print(stacktrace); |
| 33 } | 33 } |
| 34 try { | 34 try { |
| 35 int j; | 35 int j; |
| 36 i = func2(); | 36 i = func2(); |
| 37 i = 200; | 37 i = 200; |
| 38 } on MyException catch (exception, stacktrace) { | 38 } on MyException catch (exception, stacktrace) { |
| 39 i = 50; | 39 i = 50; |
| 40 print(exception.message_); | 40 print(exception.message_); |
| 41 Expect.equals((stacktrace != null), true); | 41 Expect.isNotNull(stacktrace); |
| 42 print(stacktrace); | 42 print(stacktrace); |
| 43 } finally { | 43 } finally { |
| 44 i = i + 800; | 44 i = i + 800; |
| 45 } | 45 } |
| 46 return i; | 46 return i; |
| 47 } | 47 } |
| 48 | 48 |
| 49 static int func() { | 49 static int func() { |
| 50 int i = 0; | 50 int i = 0; |
| 51 while (i < 10) { | 51 while (i < 10) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 79 | 79 |
| 80 class StackTraceTest { | 80 class StackTraceTest { |
| 81 static testMain() { | 81 static testMain() { |
| 82 Expect.equals(850, Helper.f1(1)); | 82 Expect.equals(850, Helper.f1(1)); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 main() { | 86 main() { |
| 87 StackTraceTest.testMain(); | 87 StackTraceTest.testMain(); |
| 88 } | 88 } |
| OLD | NEW |