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 library test.synthetic_accessor_properties; | 5 library test.synthetic_accessor_properties; |
6 | 6 |
7 import 'dart:mirrors'; | 7 import 'dart:mirrors'; |
8 import 'package:expect/expect.dart'; | 8 import 'package:expect/expect.dart'; |
9 | 9 |
10 import 'stringify.dart'; | 10 import 'stringify.dart'; |
11 | 11 |
12 class C { | 12 class C { |
13 String instanceField; | 13 String instanceField; |
14 final num finalInstanceField = 2; | 14 final num finalInstanceField = 2; |
15 | 15 |
16 static bool staticField; | 16 static bool staticField; |
17 static final int finalStaticField = 4; | 17 static final int finalStaticField = 4; |
18 } | 18 } |
19 | 19 |
20 String topLevelField; | 20 String topLevelField; |
21 final double finalTopLevelField = 6.0; | 21 final double finalTopLevelField = 6.0; |
22 | 22 |
23 | |
24 main() { | 23 main() { |
25 ClassMirror cm = reflectClass(C); | 24 ClassMirror cm = reflectClass(C); |
26 LibraryMirror lm = cm.owner; | 25 LibraryMirror lm = cm.owner; |
27 MethodMirror mm; | 26 MethodMirror mm; |
28 ParameterMirror pm; | 27 ParameterMirror pm; |
29 | 28 |
30 mm = cm.instanceMembers[#instanceField]; | 29 mm = cm.instanceMembers[#instanceField]; |
31 expect('Method(s(instanceField) in s(C), synthetic, getter)', mm); | 30 expect('Method(s(instanceField) in s(C), synthetic, getter)', mm); |
32 Expect.equals(reflectClass(String), mm.returnType); | 31 Expect.equals(reflectClass(String), mm.returnType); |
33 Expect.listEquals([], mm.parameters); | 32 Expect.listEquals([], mm.parameters); |
34 | 33 |
35 mm = cm.instanceMembers[const Symbol('instanceField=')]; | 34 mm = cm.instanceMembers[const Symbol('instanceField=')]; |
36 expect('Method(s(instanceField=) in s(C), synthetic, setter)', mm); | 35 expect('Method(s(instanceField=) in s(C), synthetic, setter)', mm); |
37 Expect.equals(reflectClass(String), mm.returnType); | 36 Expect.equals(reflectClass(String), mm.returnType); |
38 pm = mm.parameters.single; | 37 pm = mm.parameters.single; |
39 expect('Parameter(s(instanceField) in s(instanceField=), final,' | 38 expect( |
40 ' type = Class(s(String) in s(dart.core), top-level))', pm); | 39 'Parameter(s(instanceField) in s(instanceField=), final,' |
| 40 ' type = Class(s(String) in s(dart.core), top-level))', |
| 41 pm); |
41 | 42 |
42 mm = cm.instanceMembers[#finalInstanceField]; | 43 mm = cm.instanceMembers[#finalInstanceField]; |
43 expect('Method(s(finalInstanceField) in s(C), synthetic, getter)', mm); | 44 expect('Method(s(finalInstanceField) in s(C), synthetic, getter)', mm); |
44 Expect.equals(reflectClass(num), mm.returnType); | 45 Expect.equals(reflectClass(num), mm.returnType); |
45 Expect.listEquals([], mm.parameters); | 46 Expect.listEquals([], mm.parameters); |
46 | 47 |
47 mm = cm.instanceMembers[const Symbol('finalInstanceField=')]; | 48 mm = cm.instanceMembers[const Symbol('finalInstanceField=')]; |
48 Expect.isNull(mm); | 49 Expect.isNull(mm); |
49 | 50 |
50 | |
51 mm = cm.staticMembers[#staticField]; | 51 mm = cm.staticMembers[#staticField]; |
52 expect('Method(s(staticField) in s(C), synthetic, static, getter)', mm); | 52 expect('Method(s(staticField) in s(C), synthetic, static, getter)', mm); |
53 Expect.equals(reflectClass(bool), mm.returnType); | 53 Expect.equals(reflectClass(bool), mm.returnType); |
54 Expect.listEquals([], mm.parameters); | 54 Expect.listEquals([], mm.parameters); |
55 | 55 |
56 mm = cm.staticMembers[const Symbol('staticField=')]; | 56 mm = cm.staticMembers[const Symbol('staticField=')]; |
57 expect('Method(s(staticField=) in s(C), synthetic, static, setter)', mm); | 57 expect('Method(s(staticField=) in s(C), synthetic, static, setter)', mm); |
58 Expect.equals(reflectClass(bool), mm.returnType); | 58 Expect.equals(reflectClass(bool), mm.returnType); |
59 pm = mm.parameters.single; | 59 pm = mm.parameters.single; |
60 expect('Parameter(s(staticField) in s(staticField=), final,' | 60 expect( |
61 ' type = Class(s(bool) in s(dart.core), top-level))', pm); | 61 'Parameter(s(staticField) in s(staticField=), final,' |
| 62 ' type = Class(s(bool) in s(dart.core), top-level))', |
| 63 pm); |
62 | 64 |
63 mm = cm.staticMembers[#finalStaticField]; | 65 mm = cm.staticMembers[#finalStaticField]; |
64 expect('Method(s(finalStaticField) in s(C), synthetic, static, getter)', mm); | 66 expect('Method(s(finalStaticField) in s(C), synthetic, static, getter)', mm); |
65 Expect.equals(reflectClass(int), mm.returnType); | 67 Expect.equals(reflectClass(int), mm.returnType); |
66 Expect.listEquals([], mm.parameters); | 68 Expect.listEquals([], mm.parameters); |
67 | 69 |
68 mm = cm.staticMembers[const Symbol('finalStaticField=')]; | 70 mm = cm.staticMembers[const Symbol('finalStaticField=')]; |
69 Expect.isNull(mm); | 71 Expect.isNull(mm); |
70 } | 72 } |
OLD | NEW |