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

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

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 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
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 print(s); 22 print(s);
23 Expect.isFalse(s.contains("-1:-1"), "A"); 23 Expect.isFalse(s.contains("-1:-1"), "A");
24 Expect.isTrue(s.contains("optimized_stacktrace_line_test.dart:11"), "B"); 24 Expect.isTrue(s.contains("optimized_stacktrace_line_test.dart:11"), "B");
25 } 25 }
26 26
27 // Optimized. 27 // Optimized.
28 for (var i=0; i<10000; i++) foo(42); 28 for (var i = 0; i < 10000; i++) foo(42);
29 try { 29 try {
30 foo(null); 30 foo(null);
31 Expect.fail("Unreachable"); 31 Expect.fail("Unreachable");
32 } catch (e, stacktrace) { 32 } catch (e, stacktrace) {
33 String s = stacktrace.toString(); 33 String s = stacktrace.toString();
34 print(s); 34 print(s);
35 Expect.isFalse(s.contains("-1:-1"), "C"); 35 Expect.isFalse(s.contains("-1:-1"), "C");
36 Expect.isTrue(s.contains("optimized_stacktrace_line_test.dart:11"), "D"); 36 Expect.isTrue(s.contains("optimized_stacktrace_line_test.dart:11"), "D");
37 } 37 }
38 } 38 }
39 39
40
41 // (2) Test checked mode exceptions. 40 // (2) Test checked mode exceptions.
42 maximus(x) => moritz(x); 41 maximus(x) => moritz(x);
43 42
44 moritz(x) { 43 moritz(x) {
45 if (x == 333) return 42 ? 0 : 1; // Throws in checked mode. 44 if (x == 333) return 42 ? 0 : 1; // Throws in checked mode.
46 if (x == 777) { 45 if (x == 777) {
47 bool b = x; // Throws in checked mode. 46 bool b = x; // Throws in checked mode.
48 return b; 47 return b;
49 } 48 }
50 49
51 return x + 1; 50 return x + 1;
52 } 51 }
53 52
54 test2() { 53 test2() {
55 for (var i=0; i<100000; i++) maximus(42); 54 for (var i = 0; i < 100000; i++) maximus(42);
56 try { 55 try {
57 maximus(333); 56 maximus(333);
58 } catch (e, stacktrace) { 57 } catch (e, stacktrace) {
59 String s = stacktrace.toString(); 58 String s = stacktrace.toString();
60 print(s); 59 print(s);
61 Expect.isTrue(s.contains("maximus"), "E"); 60 Expect.isTrue(s.contains("maximus"), "E");
62 Expect.isTrue(s.contains("moritz"), "F"); 61 Expect.isTrue(s.contains("moritz"), "F");
63 Expect.isFalse(s.contains("-1:-1"), "G"); 62 Expect.isFalse(s.contains("-1:-1"), "G");
64 } 63 }
65 64
66 try { 65 try {
67 maximus(777); 66 maximus(777);
68 } catch (e, stacktrace) { 67 } catch (e, stacktrace) {
69 String s = stacktrace.toString(); 68 String s = stacktrace.toString();
70 print(s); 69 print(s);
71 Expect.isTrue(s.contains("maximus"), "H"); 70 Expect.isTrue(s.contains("maximus"), "H");
72 Expect.isTrue(s.contains("moritz"), "I"); 71 Expect.isTrue(s.contains("moritz"), "I");
73 Expect.isFalse(s.contains("-1:-1"), "J"); 72 Expect.isFalse(s.contains("-1:-1"), "J");
74 } 73 }
75 } 74 }
76 75
77 main() { 76 main() {
78 test1(); 77 test1();
79 test2(); 78 test2();
80 } 79 }
OLDNEW
« no previous file with comments | « runtime/tests/vm/dart/optimized_stacktrace_line_and_column_test.dart ('k') | runtime/tests/vm/dart/random_walk_fuzzer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698