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

Side by Side Diff: tests/kernel/unsorted/try_finally_test.dart

Issue 2451623006: Reland "Merge more Kernel infrastructure from kernel_sdk SDK fork." (Closed)
Patch Set: Fix Created 4 years, 1 month 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
(Empty)
1 // Copyright (c) 2016, 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 import 'expect.dart';
6
7 testSimpleBreak() {
8 var x = 1;
9 while (true) {
10 try {
11 x++;
12 break;
13 } finally {
14 x++;
15 break;
16 }
17 }
18 return x;
19 }
20
21 testReturnFinally() {
22 try {
23 return 1;
24 } finally {
25 return 42;
26 }
27 }
28
29 testNestedReturnFinally() {
30 try {
31 try {
32 return 1;
33 } finally {
34 return 2;
35 }
36 } finally {
37 return 42;
38 }
39 }
40
41 testReturnInsideLoop() {
42 while (true) {
43 try {
44 print("hello");
45 } finally {
46 return 42;
47 }
48 }
49 }
50
51 testStopContinueInsideLoop() {
52 while (true) {
53 try {
54 continue;
55 } finally {
56 return 42;
57 }
58 }
59 }
60
61 testStopBreakInsideLoop() {
62 var foo = 1;
63 while (true) {
64 try {
65 if (foo == 1) {
66 // 1st iteration we break.
67 break;
68 } else if (foo == 2) {
69 // 2nd iteration we return.
70 return 42;
71 }
72 } finally {
73 // 1st iteration we overrwrite break with continue.
74 if (foo == 1) {
75 foo++;
76 continue;
77 } else {
78 // Let return work
79 }
80 }
81 }
82 return foo;
83 }
84
85 testStopBreakInsideLoop2() {
86 var foo = 1;
87 while (true) {
88 try {
89 if (foo == 1) {
90 // 1st iteration we break.
91 break;
92 } else if (foo == 2) {
93 // 2nd iteration we return.
94 return -1;
95 }
96 } finally {
97 // 1st iteration we overrwrite break with continue.
98 if (foo == 1) {
99 foo++;
100 continue;
101 } else {
102 // 2nd iteration we overrwrite return with break.
103 foo = 42;
104 break;
105 }
106 }
107 }
108 return foo;
109 }
110
111 testStopContinueInsideSwitch() {
112 var foo = 1;
113 switch (foo) {
114 jump5:
115 case 5:
116 return -1;
117
118 case 1:
119 try {
120 continue jump5;
121 } finally {
122 return 42;
123 }
124 }
125 }
126
127 testStopContinueInsideSwitch2() {
128 var foo = 1;
129 switch (foo) {
130 jump5:
131 case 5:
132 return -1;
133
134 jump42:
135 case 5:
136 return 42;
137
138 case 1:
139 try {
140 continue jump5;
141 } finally {
142 continue jump42;
143 }
144 }
145 }
146
147 main() {
148 Expect.isTrue(testSimpleBreak() == 3);
149 Expect.isTrue(testReturnFinally() == 42);
150 Expect.isTrue(testNestedReturnFinally() == 42);
151 Expect.isTrue(testReturnInsideLoop() == 42);
152 Expect.isTrue(testStopContinueInsideLoop() == 42);
153 Expect.isTrue(testStopBreakInsideLoop() == 42);
154 Expect.isTrue(testStopBreakInsideLoop2() == 42);
155 Expect.isTrue(testStopContinueInsideLoop() == 42);
156 Expect.isTrue(testStopContinueInsideSwitch() == 42);
157 Expect.isTrue(testStopContinueInsideSwitch2() == 42);
158 }
OLDNEW
« no previous file with comments | « tests/kernel/unsorted/try_context_test.dart ('k') | tests/kernel/unsorted/type_args_regression_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698