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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 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 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 // Dart test program for testing execution of finally blocks after an exception 4 // Dart test program for testing execution of finally blocks after an exception
5 // is thrown from inside a local function capturing a variable. 5 // is thrown from inside a local function capturing a variable.
6 6
7 import "package:expect/expect.dart"; 7 import "package:expect/expect.dart";
8 8
9
10 class MyException { 9 class MyException {
11 const MyException(String message) : message_ = message; 10 const MyException(String message) : message_ = message;
12 final String message_; 11 final String message_;
13 } 12 }
14 13
15 class Helper { 14 class Helper {
16 static int f1(int k) { 15 static int f1(int k) {
17 var b; 16 var b;
18 try { 17 try {
19 var a = new List(10); 18 var a = new List(10);
20 int i = 0; 19 int i = 0;
21 while (i < 10) { 20 while (i < 10) {
22 int j = i; 21 int j = i;
23 a[i] = () { 22 a[i] = () {
24 if (j == 5) { 23 if (j == 5) {
25 throw new MyException("Test for exception being thrown"); 24 throw new MyException("Test for exception being thrown");
26 } 25 }
27 k += 10; 26 k += 10;
28 return j; 27 return j;
29 }; 28 };
30 if (i == 0) { 29 if (i == 0) {
31 b = a[i]; 30 b = a[i];
32 } 31 }
33 i++; 32 i++;
34 } 33 }
35 for(int i = 0; i < 10; i++) { 34 for (int i = 0; i < 10; i++) {
36 a[i](); 35 a[i]();
37 } 36 }
38 } on MyException catch (exception) { 37 } on MyException catch (exception) {
39 k += 100; 38 k += 100;
40 print(exception.message_); 39 print(exception.message_);
41 b(); 40 b();
42 } finally { 41 } finally {
43 k += 1000; 42 k += 1000;
44 b(); 43 b();
45 } 44 }
46 return k; 45 return k;
47 } 46 }
48 } 47 }
49 48
50 class ExecuteFinally7Test { 49 class ExecuteFinally7Test {
51 static testMain() { 50 static testMain() {
52 Expect.equals(1171, Helper.f1(1)); 51 Expect.equals(1171, Helper.f1(1));
53 } 52 }
54 } 53 }
55 54
56 main() { 55 main() {
57 ExecuteFinally7Test.testMain(); 56 ExecuteFinally7Test.testMain();
58 } 57 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698