OLD | NEW |
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 testing closures. | 4 // Dart test program testing closures. |
5 | 5 |
6 import "package:expect/expect.dart"; | 6 import "package:expect/expect.dart"; |
7 | 7 |
8 class LocalFunction3Test { | 8 class LocalFunction3Test { |
9 static testExceptions() { | 9 static testExceptions() { |
10 var f = (int n) { return n + 1; }; | 10 var f = (int n) { |
| 11 return n + 1; |
| 12 }; |
11 Expect.equals(true, f is Object); | 13 Expect.equals(true, f is Object); |
12 bool exception_caught = false; | 14 bool exception_caught = false; |
13 try { | 15 try { |
14 f.xyz(0); | 16 f.xyz(0); |
15 } on NoSuchMethodError catch (e) { | 17 } on NoSuchMethodError catch (e) { |
16 exception_caught = true; | 18 exception_caught = true; |
17 } | 19 } |
18 Expect.equals(true, exception_caught); | 20 Expect.equals(true, exception_caught); |
19 exception_caught = false; | 21 exception_caught = false; |
20 String f_string; | 22 String f_string; |
21 try { | 23 try { |
22 f_string = f.toString(); | 24 f_string = f.toString(); |
23 } on NoSuchMethodError catch (e) { | 25 } on NoSuchMethodError catch (e) { |
24 exception_caught = true; | 26 exception_caught = true; |
25 } | 27 } |
26 Expect.equals(false, exception_caught); | 28 Expect.equals(false, exception_caught); |
27 Expect.equals(true, f_string.startsWith("Closure")); | 29 Expect.equals(true, f_string.startsWith("Closure")); |
28 } | 30 } |
29 | 31 |
30 static testMain() { | 32 static testMain() { |
31 testExceptions(); | 33 testExceptions(); |
32 } | 34 } |
33 } | 35 } |
34 | 36 |
35 main() { | 37 main() { |
36 LocalFunction3Test.testMain(); | 38 LocalFunction3Test.testMain(); |
37 } | 39 } |
38 | |
OLD | NEW |