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 // Test that we correctly intercept super getter and setter calls. | 5 // Test that we correctly intercept super getter and setter calls. |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 | 8 |
9 var expected; | 9 var expected; |
10 | 10 |
11 class A { | 11 class A { |
12 set length(a) { Expect.equals(expected, a); } | 12 set length(a) { |
| 13 Expect.equals(expected, a); |
| 14 } |
| 15 |
13 get length => 41; | 16 get length => 41; |
14 } | 17 } |
15 | 18 |
16 class B extends A { | 19 class B extends A { |
17 test() { | 20 test() { |
18 expected = 42; | 21 expected = 42; |
19 Expect.equals(42, super.length = 42); | 22 Expect.equals(42, super.length = 42); |
20 expected = 42; | 23 expected = 42; |
21 Expect.equals(42, super.length += 1); | 24 Expect.equals(42, super.length += 1); |
22 expected = 42; | 25 expected = 42; |
23 Expect.equals(42, ++super.length); | 26 Expect.equals(42, ++super.length); |
24 expected = 40; | 27 expected = 40; |
25 Expect.equals(40, --super.length); | 28 Expect.equals(40, --super.length); |
26 expected = 42; | 29 expected = 42; |
27 Expect.equals(41, super.length++); | 30 Expect.equals(41, super.length++); |
28 expected = 40; | 31 expected = 40; |
29 Expect.equals(41, super.length--); | 32 Expect.equals(41, super.length--); |
30 Expect.equals(41, super.length); | 33 Expect.equals(41, super.length); |
31 } | 34 } |
32 } | 35 } |
33 | 36 |
34 main() { | 37 main() { |
35 // Ensures the list class is instantiated. | 38 // Ensures the list class is instantiated. |
36 print([]); | 39 print([]); |
37 new B().test(); | 40 new B().test(); |
38 } | 41 } |
OLD | NEW |