OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
6 | 6 |
7 var b; | 7 var b; |
8 var a = () { | 8 var a = () { |
9 b = 42; | 9 b = 42; |
10 }; | 10 }; |
11 | 11 |
12 var c = [new C()]; | 12 var c = [new C()]; |
13 | 13 |
14 class C { | 14 class C { |
15 nonInlinable1() { | 15 nonInlinable1() { |
16 a(); | 16 a(); |
17 } | 17 } |
18 | 18 |
19 nonInlinable2() { | 19 nonInlinable2() { |
20 var a = () { b = 42; }; | 20 var a = () { |
| 21 b = 42; |
| 22 }; |
21 a(); | 23 a(); |
22 } | 24 } |
23 } | 25 } |
24 | 26 |
25 testClosureInStaticField() { | 27 testClosureInStaticField() { |
26 var temp = c[0]; | 28 var temp = c[0]; |
27 Expect.isNull(b); | 29 Expect.isNull(b); |
28 temp.nonInlinable1(); | 30 temp.nonInlinable1(); |
29 Expect.equals(42, b); | 31 Expect.equals(42, b); |
30 b = null; | 32 b = null; |
31 } | 33 } |
32 | 34 |
33 testLocalClosure() { | 35 testLocalClosure() { |
34 var temp = c[0]; | 36 var temp = c[0]; |
35 Expect.isNull(b); | 37 Expect.isNull(b); |
36 temp.nonInlinable2(); | 38 temp.nonInlinable2(); |
37 Expect.equals(42, b); | 39 Expect.equals(42, b); |
38 } | 40 } |
39 | 41 |
40 main() { | 42 main() { |
41 testClosureInStaticField(); | 43 testClosureInStaticField(); |
42 testLocalClosure(); | 44 testLocalClosure(); |
43 } | 45 } |
OLD | NEW |