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 | 4 |
5 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 import "package:meta/meta.dart" show virtual; |
6 | 7 |
7 class GettersSettersTest { | 8 class GettersSettersTest { |
8 | 9 |
9 static int foo; | 10 static int foo; |
10 | 11 |
11 static testMain() { | 12 static testMain() { |
12 A a = new A(); | 13 A a = new A(); |
13 a.x = 2; | 14 a.x = 2; |
14 Expect.equals(2, a.x); | 15 Expect.equals(2, a.x); |
15 Expect.equals(2, a.x_); | 16 Expect.equals(2, a.x_); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 55 |
55 ReferenceField rf = new ReferenceField(); | 56 ReferenceField rf = new ReferenceField(); |
56 rf.x_ = 1; | 57 rf.x_ = 1; |
57 Expect.equals(1, rf.getIt()); | 58 Expect.equals(1, rf.getIt()); |
58 rf.setIt(2); | 59 rf.setIt(2); |
59 Expect.equals(2, rf.x_); | 60 Expect.equals(2, rf.x_); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 class A { | 64 class A { |
64 int x_; | 65 @virtual int x_; |
65 static int foo; | 66 static int foo; |
66 | 67 |
67 static get bar { | 68 static get bar { |
68 return foo; | 69 return foo; |
69 } | 70 } |
70 | 71 |
71 static set bar(newValue) { | 72 static set bar(newValue) { |
72 foo = newValue; | 73 foo = newValue; |
73 } | 74 } |
74 | 75 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 143 } |
143 | 144 |
144 int getIt() { | 145 int getIt() { |
145 return super.x_; | 146 return super.x_; |
146 } | 147 } |
147 } | 148 } |
148 | 149 |
149 main() { | 150 main() { |
150 GettersSettersTest.testMain(); | 151 GettersSettersTest.testMain(); |
151 } | 152 } |
OLD | NEW |