Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Side by Side Diff: runtime/tests/vm/dart/optimized_stacktrace_test.dart

Issue 14009004: Remove methods on StackTrace class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add dart2j issue number for unexepected stack trace. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // Test correct source positions in stack trace with optimized functions. 4 // Test correct source positions in stack trace with optimized functions.
5 import "package:expect/expect.dart"; 5 import "package:expect/expect.dart";
6 6
7 // (1) Test normal exception. 7 // (1) Test normal exception.
8 foo(x) => bar(x); 8 foo(x) => bar(x);
9 9
10 bar(x) { 10 bar(x) {
11 if (x == null) throw 42; // throw at position 11:18 11 if (x == null) throw 42; // throw at position 11:18
12 return x + 1; 12 return x + 1;
13 } 13 }
14 14
15 test1() { 15 test1() {
16 // First unoptimized. 16 // First unoptimized.
17 try { 17 try {
18 foo(null); 18 foo(null);
19 Expect.fail("Unreachable"); 19 Expect.fail("Unreachable");
20 } catch (e, stacktrace) { 20 } catch (e, stacktrace) {
21 String s = stacktrace.toString(); 21 String s = stacktrace.toString();
22 Expect.equals(-1, s.indexOf("-1:-1")); 22 Expect.isFalse(s.contains("-1:-1"));
23 Expect.notEquals(-1, s.indexOf("11:18")); 23 Expect.isTrue(s.contains("11:18"));
24 } 24 }
25 25
26 // Optimized. 26 // Optimized.
27 for (var i=0; i<10000; i++) foo(42); 27 for (var i=0; i<10000; i++) foo(42);
28 try { 28 try {
29 foo(null); 29 foo(null);
30 Expect.fail("Unreachable"); 30 Expect.fail("Unreachable");
31 } catch (e, stacktrace) { 31 } catch (e, stacktrace) {
32 String s = stacktrace.toString(); 32 String s = stacktrace.toString();
33 Expect.equals(-1, s.indexOf("-1:-1")); 33 Expect.isFalse(s.contains("-1:-1"));
34 Expect.notEquals(-1, s.indexOf("11:18")); 34 Expect.isTrue(s.contains("11:18"));
35 } 35 }
36 } 36 }
37 37
38 38
39 // (2) Test checked mode exceptions. 39 // (2) Test checked mode exceptions.
40 maximus(x) => moritz(x); 40 maximus(x) => moritz(x);
41 41
42 moritz(x) { 42 moritz(x) {
43 if (x == 333) return 42 ? 0 : 1; // Throws in checked mode. 43 if (x == 333) return 42 ? 0 : 1; // Throws in checked mode.
44 if (x == 777) { 44 if (x == 777) {
45 bool b = x; // Throws in checked mode. 45 bool b = x; // Throws in checked mode.
46 return b; 46 return b;
47 } 47 }
48 48
49 return x + 1; 49 return x + 1;
50 } 50 }
51 51
52 test2() { 52 test2() {
53 for (var i=0; i<100000; i++) maximus(42); 53 for (var i=0; i<100000; i++) maximus(42);
54 try { 54 try {
55 maximus(333); 55 maximus(333);
56 } catch (e, stacktrace) { 56 } catch (e, stacktrace) {
57 String s = stacktrace.toString(); 57 String s = stacktrace.toString();
58 print(s); 58 print(s);
59 Expect.notEquals(-1, s.indexOf("maximus")); 59 Expect.isTrue(s.contains("maximus"));
60 Expect.notEquals(-1, s.indexOf("moritz")); 60 Expect.isTrue(s.contains("moritz"));
61 Expect.equals(-1, s.indexOf("-1:-1")); 61 Expect.isFalse(s.contains("-1:-1"));
62 } 62 }
63 63
64 try { 64 try {
65 maximus(777); 65 maximus(777);
66 } catch (e, stacktrace) { 66 } catch (e, stacktrace) {
67 String s = stacktrace.toString(); 67 String s = stacktrace.toString();
68 print(s); 68 print(s);
69 Expect.notEquals(-1, s.indexOf("maximus")); 69 Expect.isTrue(s.contains("maximus"));
70 Expect.notEquals(-1, s.indexOf("moritz")); 70 Expect.isTrue(s.contains("moritz"));
71 Expect.equals(-1, s.indexOf("-1:-1")); 71 Expect.isFalse(s.contains("-1:-1"));
72 } 72 }
73 } 73 }
74 74
75 main() { 75 main() {
76 test1(); 76 test1();
77 test2(); 77 test2();
78 } 78 }
OLDNEW
« no previous file with comments | « runtime/lib/stacktrace_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/core_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698