| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 // Tests dangling else. The VM should not have any problems, but dart2js or | 4 // Tests dangling else. The VM should not have any problems, but dart2js or |
| 5 // dart2dart could get this wrong. | 5 // dart2dart could get this wrong. |
| 6 | 6 |
| 7 import "package:expect/expect.dart"; |
| 8 |
| 7 nestedIf1(notTrue) { | 9 nestedIf1(notTrue) { |
| 8 if (notTrue) return 'bad input'; | 10 if (notTrue) return 'bad input'; |
| 9 if (notTrue) { | 11 if (notTrue) { |
| 10 if (notTrue) { | 12 if (notTrue) { |
| 11 return 'bad'; | 13 return 'bad'; |
| 12 } | 14 } |
| 13 } else { | 15 } else { |
| 14 return 'good'; | 16 return 'good'; |
| 15 } | 17 } |
| 16 return 'bug'; | 18 return 'bug'; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 return 'bug'; | 75 return 'bug'; |
| 74 } | 76 } |
| 75 | 77 |
| 76 main() { | 78 main() { |
| 77 Expect.equals('good', nestedIf1(false)); | 79 Expect.equals('good', nestedIf1(false)); |
| 78 Expect.equals('good', nestedIf2(false)); | 80 Expect.equals('good', nestedIf2(false)); |
| 79 Expect.equals('good', nestedWhile(false)); | 81 Expect.equals('good', nestedWhile(false)); |
| 80 Expect.equals('good', nestedFor(false)); | 82 Expect.equals('good', nestedFor(false)); |
| 81 Expect.equals('good', nestedLabeledStatement(false)); | 83 Expect.equals('good', nestedLabeledStatement(false)); |
| 82 } | 84 } |
| OLD | NEW |