OLD | NEW |
1 // (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // (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 func1() { | 7 void func1() { |
8 throw new Exception("Test peanut gallery request for Full stacktrace"); | 8 throw new Exception("Test full stacktrace"); |
9 } | 9 } |
10 void func2() { | 10 void func2() { |
11 func1(); | 11 func1(); |
12 } | 12 } |
13 void func3() { | 13 void func3() { |
14 try { | 14 try { |
15 func2(); | 15 func2(); |
16 } on Object catch(e, s) { | 16 } on Object catch(e, s) { |
17 print(e); | 17 var fullTrace = s.toString(); |
18 | 18 Expect.isTrue(fullTrace.contains("func1")); |
19 var full_trace = s.fullStackTrace; | 19 Expect.isTrue(fullTrace.contains("func2")); |
20 Expect.isTrue(full_trace.contains("func1")); | 20 Expect.isTrue(fullTrace.contains("func3")); |
21 Expect.isTrue(full_trace.contains("func2")); | 21 Expect.isTrue(fullTrace.contains("func4")); |
22 Expect.isTrue(full_trace.contains("func3")); | 22 Expect.isTrue(fullTrace.contains("func5")); |
23 Expect.isTrue(full_trace.contains("func4")); | 23 Expect.isTrue(fullTrace.contains("func6")); |
24 Expect.isTrue(full_trace.contains("func5")); | 24 Expect.isTrue(fullTrace.contains("main")); |
25 Expect.isTrue(full_trace.contains("func6")); | |
26 Expect.isTrue(full_trace.contains("main")); | |
27 | |
28 var trace = s.stackTrace; | |
29 Expect.isTrue(trace.contains("func1")); | |
30 Expect.isTrue(trace.contains("func2")); | |
31 Expect.isTrue(trace.contains("func3")); | |
32 | |
33 Expect.isFalse(trace.contains("func4")); | |
34 Expect.isFalse(trace.contains("func5")); | |
35 Expect.isFalse(trace.contains("func6")); | |
36 Expect.isFalse(trace.contains("main")); | |
37 | |
38 print(s); | |
39 | |
40 print("Full stack trace"); | |
41 print(full_trace); | |
42 | |
43 print("Stack trace"); | |
44 print(trace); | |
45 } | 25 } |
46 } | 26 } |
47 int func4() { | 27 int func4() { |
48 func3(); | 28 func3(); |
49 return 1; | 29 return 1; |
50 } | 30 } |
51 int func5() { | 31 int func5() { |
52 func4(); | 32 func4(); |
53 return 1; | 33 return 1; |
54 } | 34 } |
55 int func6() { | 35 int func6() { |
56 func5(); | 36 func5(); |
57 return 1; | 37 return 1; |
58 } | 38 } |
59 main() { | 39 main() { |
60 var i = func6(); | 40 var i = func6(); |
61 Expect.equals(1, i); | 41 Expect.equals(1, i); |
62 } | 42 } |
OLD | NEW |