OLD | NEW |
(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 'package:expect/expect.dart'; |
| 6 |
| 7 throwValue(val) => throw val; |
| 8 |
| 9 f1() { |
| 10 var a = 0; |
| 11 var b = 0; |
| 12 var c = 0; |
| 13 var d = 0; |
| 14 for (var i = 0; i < 10; i++) { |
| 15 try { |
| 16 for (var j = 0; j < 11; j++) { |
| 17 try { |
| 18 capture() => [i, j, a, b, c, d]; |
| 19 throwValue(j == 10 ? "${j}" : j); |
| 20 } on num catch (e) { |
| 21 a += j; |
| 22 b -= e; |
| 23 } |
| 24 } |
| 25 } catch (e) { |
| 26 c++; |
| 27 d += int.parse(e); |
| 28 } |
| 29 } |
| 30 return [a, b, c, d]; |
| 31 } |
| 32 |
| 33 |
| 34 f2() { |
| 35 var a = 0; |
| 36 var b = 0; |
| 37 var c = 0; |
| 38 var d = 0; |
| 39 for (var i = 0; i < 10; i++) { |
| 40 try { |
| 41 for (var j = 0; j < 11; j++) { |
| 42 try { |
| 43 capture() => [i, j, a, b, c, d]; |
| 44 throwValue(j == 10 ? "${j}" : j); |
| 45 } on num catch (e) { |
| 46 a += j; |
| 47 b -= e; |
| 48 } |
| 49 } |
| 50 } catch (e) { |
| 51 capture() => e; |
| 52 c++; |
| 53 d += int.parse(e); |
| 54 } |
| 55 } |
| 56 return [a, b, c, d]; |
| 57 } |
| 58 |
| 59 |
| 60 f3() { |
| 61 var a = 0; |
| 62 var b = 0; |
| 63 var c = 0; |
| 64 var d = 0; |
| 65 for (var i = 0; i < 10; i++) { |
| 66 try { |
| 67 for (var j = 0; j < 11; j++) { |
| 68 try { |
| 69 capture() => [i, j, a, b, c, d]; |
| 70 throwValue(j == 10 ? "${j}" : j); |
| 71 } on num catch (e) { |
| 72 a += j; |
| 73 b -= e; |
| 74 } |
| 75 } |
| 76 } catch (e) { |
| 77 capture() => e; |
| 78 c++; |
| 79 d += int.parse(e); |
| 80 continue; |
| 81 } |
| 82 } |
| 83 return [a, b, c, d]; |
| 84 } |
| 85 |
| 86 |
| 87 main() { |
| 88 Expect.listEquals([450, -450, 10, 100], f1()); |
| 89 Expect.listEquals([450, -450, 10, 100], f2()); |
| 90 Expect.listEquals([450, -450, 10, 100], f3()); |
| 91 } |
OLD | NEW |