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

Side by Side Diff: tests/language/dangling_else_test.dart

Issue 10837236: Fix dangling else. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add forgotten test. Created 8 years, 4 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
(Empty)
1 // Copyright (c) 2012, 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 // Tests dangling else. The VM should not have any problems, but dart2js or
5 // dart2dart could get this wrong.
6
7 nestedIf1(notTrue) {
8 if (notTrue) return 'bad input';
9 if (notTrue) {
10 if (notTrue) {
11 return 'bad';
12 }
13 } else {
14 return 'good';
15 }
16 return 'bug';
17 }
18
19 nestedIf2(notTrue) {
20 if (notTrue) return 'bad input';
21 if (notTrue) {
22 if (notTrue) {
23 return 'bad';
24 } else {
25 if (notTrue) {
26 return 'bad';
27 }
28 }
29 } else {
30 return 'good';
31 }
32 return 'bug';
33 }
34
35 nestedWhile(notTrue) {
36 if (notTrue) return 'bad input';
37 if (notTrue) {
38 while(notTrue) {
39 if (notTrue) {
40 return 'bad';
41 }
42 }
43 } else {
44 return 'good';
45 }
46 return 'bug';
47 }
48
49 nestedFor(notTrue) {
50 if (notTrue) return 'bad input';
51 if (notTrue) {
52 for (int i = 0; i < 3; i++) {
53 if (i == 0) {
54 return 'bad';
55 }
56 }
57 } else {
58 return 'good';
59 }
60 return 'bug';
61 }
62
63 nestedLabeledStatement(notTrue) {
64 if (notTrue) return 'bad input';
65 if (notTrue) {
66 label:
67 if (notTrue) {
68 break label;
69 }
70 } else {
71 return 'good';
72 }
73 return 'bug';
74 }
75
76 main() {
77 Expect.equals('good', nestedIf1(false));
78 Expect.equals('good', nestedIf2(false));
79 Expect.equals('good', nestedWhile(false));
80 Expect.equals('good', nestedFor(false));
81 Expect.equals('good', nestedLabeledStatement(false));
82 }
OLDNEW
« lib/compiler/implementation/js/printer.dart ('K') | « lib/compiler/implementation/js/printer.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698