Chromium Code Reviews| Index: tests/language/stack_trace_test.dart |
| =================================================================== |
| --- tests/language/stack_trace_test.dart (revision 26933) |
| +++ tests/language/stack_trace_test.dart (working copy) |
| @@ -83,6 +83,63 @@ |
| } |
| } |
| + |
| +// Test that the full stack trace is generated for rethrow. |
| +class RethrowStacktraceTest { |
| + var config = 0; |
| + |
| + a() { |
| + throw "Progy"; |
| + } |
| + |
| + b() { |
| + a(); |
| + } |
| + |
| + c() { |
| + if (config == 0) { |
| + try { |
| + b(); |
| + } catch (e) { |
| + rethrow; |
| + } |
| + } else { |
| + try { |
| + b(); |
| + } catch (e, s) { |
| + rethrow; |
| + } |
| + } |
| + } |
| + |
| + d() { |
| + c(); |
| + } |
| + |
| + testBoth() { |
| + int prev_len = -1; |
| + for (config = 0; config < 2; config++) { |
| + try { |
| + d(); |
| + } catch (e, s) { |
| + if (prev_len < 0) { |
| + prev_len = s.toString().length; |
| + } else { |
| + // Check both stacktraces have same length. |
| + Expect.equals(prev_len, s.toString().length); |
|
Ivan Posva
2013/08/31 00:06:23
How about just checking that a() is in the stacktr
srdjan
2013/08/31 00:18:06
renamed a to issue12940 and checking for it.
|
| + } |
| + } |
| + } |
| + } |
| + |
| + static testMain() { |
| + var test = new RethrowStacktraceTest(); |
| + test.testBoth(); |
| + } |
| +} |
| + |
| + |
| main() { |
| StackTraceTest.testMain(); |
| + RethrowStacktraceTest.testMain(); |
| } |