| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011, 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 // Dart test program for testing execution of finally blocks on | |
| 5 // control flow breaks because of 'return', 'continue' etc. | |
| 6 | |
| 7 | |
| 8 class Helper { | |
| 9 Helper() : i = 0 { } | |
| 10 | |
| 11 int f1() { | |
| 12 try { | |
| 13 try { | |
| 14 int j; | |
| 15 j = func(); | |
| 16 L1: | |
| 17 while (i <= 0) { | |
| 18 if (i == 0) { | |
| 19 try { | |
| 20 i = 1; | |
| 21 func(); | |
| 22 try { | |
| 23 int j; | |
| 24 j = func(); | |
| 25 while (j < 50) { | |
| 26 j += func(); | |
| 27 if (j > 30) { | |
| 28 continue L1; // Break out of nested try blocks. | |
| 29 } | |
| 30 } | |
| 31 i = 200000; // Should not get executed. | |
| 32 } finally { | |
| 33 i = i + 200; // Should get executed when we break out. | |
| 34 } | |
| 35 } finally { | |
| 36 i = i + 400; // Should get executed when we break out. | |
| 37 } | |
| 38 } | |
| 39 } | |
| 40 } finally { | |
| 41 i = i + 800; // Should get executed as normal control flow. | |
| 42 } | |
| 43 return i; // Value of i should be 1401. | |
| 44 } finally { | |
| 45 i = i + 1600; // Should get executed as part of return above. | |
| 46 } | |
| 47 i = i + 2000000; // Should not get executed. | |
| 48 return 1; | |
| 49 } | |
| 50 | |
| 51 static int func() { | |
| 52 int i = 0; | |
| 53 while (i < 10) { | |
| 54 i++; | |
| 55 } | |
| 56 return i; | |
| 57 } | |
| 58 | |
| 59 int i; | |
| 60 } | |
| 61 | |
| 62 class ExecuteFinally3Test { | |
| 63 static testMain() { | |
| 64 Helper obj = new Helper(); | |
| 65 Expect.equals(1401, obj.f1()); | |
| 66 Expect.equals(3001, obj.i); | |
| 67 } | |
| 68 } | |
| 69 | |
| 70 main() { | |
| 71 ExecuteFinally3Test.testMain(); | |
| 72 } | |
| OLD | NEW |