 Chromium Code Reviews
 Chromium Code Reviews Issue 14009004:
  Remove methods on StackTrace class.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
    
  
    Issue 14009004:
  Remove methods on StackTrace class.  (Closed) 
  Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart| 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 // This test assumes that all called functions occur in the stack trace. | |
| 8 // This might not be the case if inlining methods. | |
| 
Ivan Posva
2013/04/12 03:13:10
This is a current limitation of dart2js and not so
 
Lasse Reichstein Nielsen
2013/04/15 11:37:22
I'll remove this for now, and keep it in the statu
 | |
| 9 | |
| 7 void func1() { | 10 void func1() { | 
| 8 throw new Exception("Test peanut gallery request for Full stacktrace"); | 11 throw new Exception("Test full stacktrace"); | 
| 9 } | 12 } | 
| 10 void func2() { | 13 void func2() { | 
| 11 func1(); | 14 func1(); | 
| 12 } | 15 } | 
| 13 void func3() { | 16 void func3() { | 
| 14 try { | 17 try { | 
| 15 func2(); | 18 func2(); | 
| 16 } on Object catch(e, s) { | 19 } on Object catch(e, s) { | 
| 17 print(e); | 20 var fullTrace = s.toString(); | 
| 18 | 21 Expect.isTrue(fullTrace.contains("func1")); | 
| 19 var full_trace = s.fullStackTrace; | 22 Expect.isTrue(fullTrace.contains("func2")); | 
| 20 Expect.isTrue(full_trace.contains("func1")); | 23 Expect.isTrue(fullTrace.contains("func3")); | 
| 21 Expect.isTrue(full_trace.contains("func2")); | 24 Expect.isTrue(fullTrace.contains("func4")); | 
| 22 Expect.isTrue(full_trace.contains("func3")); | 25 Expect.isTrue(fullTrace.contains("func5")); | 
| 23 Expect.isTrue(full_trace.contains("func4")); | 26 Expect.isTrue(fullTrace.contains("func6")); | 
| 24 Expect.isTrue(full_trace.contains("func5")); | 27 Expect.isTrue(fullTrace.contains("func7")); | 
| 25 Expect.isTrue(full_trace.contains("func6")); | 28 Expect.isTrue(fullTrace.contains("main")); | 
| 26 Expect.isTrue(full_trace.contains("func7")); | |
| 27 Expect.isTrue(full_trace.contains("main")); | |
| 28 | |
| 29 var trace = s.stackTrace; | |
| 30 Expect.isTrue(trace.contains("func1")); | |
| 31 Expect.isTrue(trace.contains("func2")); | |
| 32 Expect.isTrue(trace.contains("func3")); | |
| 33 | |
| 34 Expect.isFalse(trace.contains("func4")); | |
| 35 Expect.isFalse(trace.contains("func5")); | |
| 36 Expect.isFalse(trace.contains("func6")); | |
| 37 Expect.isFalse(trace.contains("func7")); | |
| 38 Expect.isFalse(trace.contains("main")); | |
| 39 | |
| 40 print(s); | |
| 41 | |
| 42 print("Full stack trace"); | |
| 43 print(full_trace); | |
| 44 | |
| 45 print("Stack trace"); | |
| 46 print(trace); | |
| 47 | 29 | 
| 48 throw; // This is a rethrow. | 30 throw; // This is a rethrow. | 
| 49 } | 31 } | 
| 50 } | 32 } | 
| 51 int func4() { | 33 int func4() { | 
| 52 func3(); | 34 func3(); | 
| 53 return 1; | 35 return 1; | 
| 54 } | 36 } | 
| 55 int func5() { | 37 int func5() { | 
| 56 try { | 38 try { | 
| 57 func4(); | 39 func4(); | 
| 58 } on Object catch(e, s) { | 40 } on Object catch(e, s) { | 
| 59 | 41 var fullTrace = s.toString(); | 
| 60 var full_trace = s.fullStackTrace; | 42 Expect.isTrue(fullTrace.contains("func1")); | 
| 61 print(full_trace); | 43 Expect.isTrue(fullTrace.contains("func2")); | 
| 62 Expect.isTrue(full_trace.contains("func1")); | 44 Expect.isTrue(fullTrace.contains("func3")); | 
| 63 Expect.isTrue(full_trace.contains("func2")); | 45 Expect.isTrue(fullTrace.contains("func4")); | 
| 64 Expect.isTrue(full_trace.contains("func3")); | 46 Expect.isTrue(fullTrace.contains("func5")); | 
| 65 Expect.isTrue(full_trace.contains("func4")); | 47 Expect.isTrue(fullTrace.contains("func6")); | 
| 66 Expect.isTrue(full_trace.contains("func5")); | 48 Expect.isTrue(fullTrace.contains("func7")); | 
| 67 Expect.isTrue(full_trace.contains("func6")); | 49 Expect.isTrue(fullTrace.contains("main")); | 
| 68 Expect.isTrue(full_trace.contains("func7")); | |
| 69 Expect.isTrue(full_trace.contains("main")); | |
| 70 | |
| 71 var trace = s.stackTrace; | |
| 72 Expect.isTrue(trace.contains("func1")); | |
| 73 Expect.isTrue(trace.contains("func2")); | |
| 74 Expect.isTrue(trace.contains("func3")); | |
| 75 Expect.isTrue(trace.contains("func4")); | |
| 76 Expect.isTrue(trace.contains("func5")); | |
| 77 | |
| 78 Expect.isFalse(trace.contains("func6")); | |
| 79 Expect.isFalse(trace.contains("func7")); | |
| 80 Expect.isFalse(trace.contains("main")); | |
| 81 | |
| 82 print(s); | |
| 83 | |
| 84 print("Full stack trace"); | |
| 85 print(full_trace); | |
| 86 | |
| 87 print("Stack trace"); | |
| 88 print(trace); | |
| 89 } | 50 } | 
| 90 return 1; | 51 return 1; | 
| 91 } | 52 } | 
| 92 int func6() { | 53 int func6() { | 
| 93 func5(); | 54 func5(); | 
| 94 return 1; | 55 return 1; | 
| 95 } | 56 } | 
| 96 int func7() { | 57 int func7() { | 
| 97 func6(); | 58 func6(); | 
| 98 return 1; | 59 return 1; | 
| 99 } | 60 } | 
| 100 main() { | 61 main() { | 
| 101 var i = func7(); | 62 var i = func7(); | 
| 102 Expect.equals(1, i); | 63 Expect.equals(1, i); | 
| 103 } | 64 } | 
| OLD | NEW |