| 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 | 4 |
| 5 class GettersSettersTest { | 5 class GettersSettersTest { |
| 6 | 6 |
| 7 static int foo; | 7 static int foo; |
| 8 | 8 |
| 9 static get bar() { | 9 static get bar { |
| 10 return foo; | 10 return foo; |
| 11 } | 11 } |
| 12 | 12 |
| 13 static set bar(newValue) { | 13 static set bar(newValue) { |
| 14 foo = newValue; | 14 foo = newValue; |
| 15 } | 15 } |
| 16 | 16 |
| 17 static testMain() { | 17 static testMain() { |
| 18 A a = new A(); | 18 A a = new A(); |
| 19 a.x = 2; | 19 a.x = 2; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Expect.equals(43, A.foo); | 62 Expect.equals(43, A.foo); |
| 63 Expect.equals(43, A.bar); | 63 Expect.equals(43, A.bar); |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 class A { | 67 class A { |
| 68 A(); | 68 A(); |
| 69 int x_; | 69 int x_; |
| 70 static int foo; | 70 static int foo; |
| 71 | 71 |
| 72 static get bar() { | 72 static get bar { |
| 73 return foo; | 73 return foo; |
| 74 } | 74 } |
| 75 | 75 |
| 76 static set bar(newValue) { | 76 static set bar(newValue) { |
| 77 foo = newValue; | 77 foo = newValue; |
| 78 } | 78 } |
| 79 | 79 |
| 80 int get x() { | 80 int get x { |
| 81 return x_; | 81 return x_; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void set x(int value) { | 84 void set x(int value) { |
| 85 x_ = value; | 85 x_ = value; |
| 86 } | 86 } |
| 87 | 87 |
| 88 bool isXPositive() { | 88 bool isXPositive() { |
| 89 return x > 0; | 89 return x > 0; |
| 90 } | 90 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 B(); | 106 B(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 class C extends A { | 109 class C extends A { |
| 110 int y_; | 110 int y_; |
| 111 | 111 |
| 112 C() { | 112 C() { |
| 113 this.x_ = 0; | 113 this.x_ = 0; |
| 114 } | 114 } |
| 115 | 115 |
| 116 int get x() { | 116 int get x { |
| 117 return y_; | 117 return y_; |
| 118 } | 118 } |
| 119 | 119 |
| 120 void set x(int value) { | 120 void set x(int value) { |
| 121 y_ = value; | 121 y_ = value; |
| 122 } | 122 } |
| 123 } | 123 } |
| 124 | 124 |
| 125 main() { | 125 main() { |
| 126 GettersSettersTest.testMain(); | 126 GettersSettersTest.testMain(); |
| 127 } | 127 } |
| OLD | NEW |