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

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

Issue 12049039: Fix source position for stack traces with optimized top function. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: avoid default arguments by using pending_deoptimization_env_ Created 7 years, 10 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
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | runtime/tests/vm/vm.status » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Test correct source positions in stack trace with optimized functions.
6
7 // (1) Test normal exception.
8 foo(x) => bar(x);
9
10 bar(x) {
11 if (x == null) throw 42; // throw at position 11:18
12 return x + 1;
13 }
14
15 test1() {
16 for (var i=0; i<10000; i++) foo(42);
srdjan 2013/01/28 18:03:58 You may attempt the test below for unoptimized cod
Florian Schneider 2013/01/29 12:19:07 Done.
17 try {
18 foo(null);
19 Expect.isTrue(false); // Unreachable.
srdjan 2013/01/28 18:03:58 Expect.fail(....);
Florian Schneider 2013/01/29 12:19:07 Done.
20 } catch (e, stacktrace) {
21 String s = stacktrace.toString();
22 Expect.equals(-1, s.indexOf("-1:-1"));
23 Expect.notEquals(-1, s.indexOf("11:18"));
24 }
25 }
26
27
28 // (2) Test checked mode exceptions.
29 max(x) => moritz(x);
srdjan 2013/01/28 18:03:58 I love the Max & Moritz theme, but max could ve co
Florian Schneider 2013/01/29 12:19:07 Renamed to maximus.
30
31 moritz(x) {
32 if (x == 333) return 42 ? 0 : 1; // Throws in checked mode.
33 if (x == 777) {
34 bool b = x; // Throws in checked mode.
35 return b;
36 }
37
38 return x + 1;
39 }
40
41 test2() {
42 for (var i=0; i<100000; i++) max(42);
43 try {
44 max(333);
45 } catch (e, stacktrace) {
46 String s = stacktrace.toString();
47 print(s);
48 Expect.notEquals(-1, s.indexOf("max"));
49 Expect.notEquals(-1, s.indexOf("moritz"));
50 Expect.equals(-1, s.indexOf("-1:-1"));
51 }
52
53 try {
54 max(777);
55 } catch (e, stacktrace) {
56 String s = stacktrace.toString();
57 print(s);
58 Expect.notEquals(-1, s.indexOf("max"));
59 Expect.notEquals(-1, s.indexOf("moritz"));
60 Expect.equals(-1, s.indexOf("-1:-1"));
61 }
62 }
63
64 main() {
65 test1();
66 test2();
67 }
OLDNEW
« no previous file with comments | « no previous file | runtime/tests/vm/vm.status » ('j') | runtime/tests/vm/vm.status » ('J')

Powered by Google App Engine
This is Rietveld 408576698