OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 // Verifies behavior with a static getter, but no field and no setter. | 4 // Verifies behavior with a static getter, but no field and no setter. |
5 | 5 |
6 import "package:expect/expect.dart"; | |
7 | |
8 class Example { | 6 class Example { |
9 static int _var = 1; | 7 static int _var = 1; |
10 static int get nextVar => _var++; | 8 static int get nextVar => _var++; |
11 Example() { | 9 Example() { |
12 { | 10 { |
13 bool flag_exception = false; | 11 bool flag_exception = false; |
14 try { | 12 try { |
15 nextVar++; | 13 nextVar++; |
16 } catch (excpt) { | 14 } catch (excpt) { |
17 flag_exception = true; | 15 flag_exception = true; |
(...skipping 24 matching lines...) Expand all Loading... |
42 static int _var = 1; | 40 static int _var = 1; |
43 static int get nextVar => _var++; | 41 static int get nextVar => _var++; |
44 Example2() : super(nextVar) { } // No 'this' in scope. | 42 Example2() : super(nextVar) { } // No 'this' in scope. |
45 } | 43 } |
46 | 44 |
47 void main() { | 45 void main() { |
48 Example x = new Example(); | 46 Example x = new Example(); |
49 Example.test(); | 47 Example.test(); |
50 Example2 x2 = new Example2(); | 48 Example2 x2 = new Example2(); |
51 } | 49 } |
OLD | NEW |