Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
|
asgerf
2014/05/22 13:49:35
Renamed to rewrite_nested_if1_test.dart
| |
| 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 'package:expect/expect.dart'; | |
| 6 | |
| 7 var global; | |
| 8 | |
| 9 setGlobal(v) { | |
| 10 global = v; | |
| 11 } | |
| 12 | |
| 13 check_true_true(x, y, v) { | |
| 14 if (x) { | |
| 15 if (y) { | |
| 16 setGlobal(v); | |
| 17 } | |
| 18 } | |
| 19 } | |
| 20 | |
| 21 check_false_true(x, y, v) { | |
| 22 if (x) { | |
| 23 | |
| 24 } else { | |
| 25 if (y) { | |
| 26 setGlobal(v); | |
| 27 } | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 check_true_false(x, y, v) { | |
| 32 if (x) { | |
| 33 if (y) { | |
| 34 | |
| 35 } else { | |
| 36 setGlobal(v); | |
| 37 } | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 check_false_false(x, y, v) { | |
| 42 if (x) { | |
| 43 | |
| 44 } else { | |
| 45 if (y) { | |
| 46 | |
| 47 } else { | |
| 48 setGlobal(v); | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 | |
| 54 main() { | |
| 55 check_true_true(true, true, 4); | |
| 56 check_true_true(false, false, 1); | |
| 57 check_true_true(false, true, 2); | |
| 58 check_true_true(true, false, 3); | |
| 59 | |
| 60 Expect.equals(4, global); | |
| 61 | |
| 62 check_true_false(false, false, 1); | |
| 63 check_true_false(false, true, 2); | |
| 64 check_true_false(true, false, 3); | |
| 65 check_true_false(true, true, 4); | |
| 66 | |
| 67 Expect.equals(3, global); | |
| 68 | |
| 69 check_false_true(false, false, 1); | |
| 70 check_false_true(false, true, 2); | |
| 71 check_false_true(true, false, 3); | |
| 72 check_false_true(true, true, 4); | |
| 73 | |
| 74 Expect.equals(2, global); | |
| 75 | |
| 76 check_false_false(false, false, 1); | |
| 77 check_false_false(false, true, 2); | |
| 78 check_false_false(true, false, 3); | |
| 79 check_false_false(true, true, 4); | |
| 80 | |
| 81 Expect.equals(1, global); | |
| 82 } | |
| OLD | NEW |