OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 var sideEffectCounter = 0; | 5 var sideEffectCounter = 0; |
6 | 6 |
7 final finalConstGlobal = "finalConstGlobal"; | 7 final finalConstGlobal = "finalConstGlobal"; |
8 final finalNonConstGlobal = (() { | 8 final finalNonConstGlobal = (() { |
9 sideEffectCounter++; | 9 sideEffectCounter++; |
10 return "finalNonConstGlobal"; | 10 return "finalNonConstGlobal"; |
11 }()); | 11 }()); |
12 | 12 |
13 var lazyConstGlobal = "lazyConstGlobal"; | 13 var lazyConstGlobal = "lazyConstGlobal"; |
14 // Regression test for bug #21840. | 14 // Regression test for bug #21840. |
15 var const1Global = const {}; | 15 var const1Global = const {}; |
16 final lazyConstGlobal2 = const1Global; | 16 final lazyConstGlobal2 = const1Global; |
17 | 17 |
18 var lazyNonConstGlobal = (() { | 18 var lazyNonConstGlobal = (() { |
19 sideEffectCounter++; | 19 sideEffectCounter++; |
20 return "lazyNonConstGlobal"; | 20 return "lazyNonConstGlobal"; |
21 }()); | 21 }()); |
22 | 22 |
23 readFinalConstGlobal() => finalConstGlobal; | 23 readFinalConstGlobal() => finalConstGlobal; |
24 readFinalNonConstGlobal() => finalNonConstGlobal; | 24 readFinalNonConstGlobal() => finalNonConstGlobal; |
25 readLazyConstGlobal() => lazyConstGlobal; | 25 readLazyConstGlobal() => lazyConstGlobal; |
26 readLazyNonConstGlobal() => lazyNonConstGlobal; | 26 readLazyNonConstGlobal() => lazyNonConstGlobal; |
27 writeLazyConstGlobal(x) { lazyConstGlobal = x; } | 27 writeLazyConstGlobal(x) { |
28 writeLazyNonConstGlobal(x) { lazyNonConstGlobal = x; } | 28 lazyConstGlobal = x; |
| 29 } |
| 30 |
| 31 writeLazyNonConstGlobal(x) { |
| 32 lazyNonConstGlobal = x; |
| 33 } |
OLD | NEW |