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.library_declarations_test; | 5 library test.library_declarations_test; |
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 import 'declarations_model.dart' as declarations_model; | 11 import 'declarations_model.dart' as declarations_model; |
12 | 12 |
13 main() { | 13 main() { |
14 LibraryMirror lm = | 14 LibraryMirror lm = |
15 currentMirrorSystem().findLibrary(#test.declarations_model); | 15 currentMirrorSystem().findLibrary(#test.declarations_model); |
16 | 16 |
17 Expect.setEquals([ | 17 Expect.setEquals( |
18 'Variable(s(_libraryVariable)' | 18 ['Variable(s(_libraryVariable)' |
19 ' in s(test.declarations_model), private, top-level, static)', | 19 ' in s(test.declarations_model), private, top-level, static)', |
20 'Variable(s(libraryVariable)' | 20 'Variable(s(libraryVariable)' |
21 ' in s(test.declarations_model), top-level, static)' | 21 ' in s(test.declarations_model), top-level, static)'], |
22 ], lm.declarations.values.where((dm) => dm is VariableMirror).map(stringify), | 22 lm.declarations.values.where((dm) => dm is VariableMirror).map(stringify), |
23 'variables'); | 23 'variables'); |
24 | 24 |
25 // dart2js stops testing here. | 25 // dart2js stops testing here. |
26 return; // //# 01: ok | 26 return; // //# 01: ok |
27 | 27 |
28 Expect.setEquals( | 28 Expect.setEquals( |
29 [ | 29 ['Method(s(_libraryGetter)' |
30 'Method(s(_libraryGetter)' | 30 ' in s(test.declarations_model), private, top-level, static, getter)', |
31 ' in s(test.declarations_model), private, top-level, static, getter)
', | 31 'Method(s(libraryGetter)' |
32 'Method(s(libraryGetter)' | 32 ' in s(test.declarations_model), top-level, static, getter)'], |
33 ' in s(test.declarations_model), top-level, static, getter)' | 33 lm.declarations.values |
34 ], | 34 .where((dm) => dm is MethodMirror && dm.isGetter).map(stringify), |
35 lm.declarations.values | 35 'getters'); |
36 .where((dm) => dm is MethodMirror && dm.isGetter) | |
37 .map(stringify), | |
38 'getters'); | |
39 | 36 |
40 Expect.setEquals( | 37 Expect.setEquals( |
41 [ | 38 ['Method(s(_librarySetter=)' |
42 'Method(s(_librarySetter=)' | 39 ' in s(test.declarations_model), private, top-level, static, setter)', |
43 ' in s(test.declarations_model), private, top-level, static, setter)
', | 40 'Method(s(librarySetter=)' |
44 'Method(s(librarySetter=)' | 41 ' in s(test.declarations_model), top-level, static, setter)'], |
45 ' in s(test.declarations_model), top-level, static, setter)' | 42 lm.declarations.values |
46 ], | 43 .where((dm) => dm is MethodMirror && dm.isSetter).map(stringify), |
47 lm.declarations.values | 44 'setters'); |
48 .where((dm) => dm is MethodMirror && dm.isSetter) | |
49 .map(stringify), | |
50 'setters'); | |
51 | 45 |
52 Expect.setEquals( | 46 Expect.setEquals( |
53 [ | 47 ['Method(s(_libraryMethod)' |
54 'Method(s(_libraryMethod)' | 48 ' in s(test.declarations_model), private, top-level, static)', |
55 ' in s(test.declarations_model), private, top-level, static)', | 49 'Method(s(libraryMethod)' |
56 'Method(s(libraryMethod)' | 50 ' in s(test.declarations_model), top-level, static)'], |
57 ' in s(test.declarations_model), top-level, static)' | 51 lm.declarations.values |
58 ], | 52 .where((dm) => dm is MethodMirror && dm.isRegularMethod).map(stringify), |
59 lm.declarations.values | 53 'regular methods'); |
60 .where((dm) => dm is MethodMirror && dm.isRegularMethod) | |
61 .map(stringify), | |
62 'regular methods'); | |
63 | 54 |
64 Expect.setEquals([ | 55 Expect.setEquals( |
65 'Class(s(Class) in s(test.declarations_model), top-level)', | 56 ['Class(s(Class) in s(test.declarations_model), top-level)', |
66 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', | 57 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', |
67 'Class(s(Interface) in s(test.declarations_model), top-level)', | 58 'Class(s(Interface) in s(test.declarations_model), top-level)', |
68 'Class(s(Mixin) in s(test.declarations_model), top-level)', | 59 'Class(s(Mixin) in s(test.declarations_model), top-level)', |
69 'Class(s(Superclass) in s(test.declarations_model), top-level)', | 60 'Class(s(Superclass) in s(test.declarations_model), top-level)', |
70 'Class(s(_PrivateClass)' | 61 'Class(s(_PrivateClass)' |
71 ' in s(test.declarations_model), private, top-level)' | 62 ' in s(test.declarations_model), private, top-level)'], |
72 ], lm.declarations.values.where((dm) => dm is ClassMirror).map(stringify), | 63 lm.declarations.values |
73 'classes'); | 64 .where((dm) => dm is ClassMirror).map(stringify), |
| 65 'classes'); |
74 | 66 |
75 Expect.setEquals([ | 67 Expect.setEquals( |
76 'Class(s(Class) in s(test.declarations_model), top-level)', | 68 ['Class(s(Class) in s(test.declarations_model), top-level)', |
77 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', | 69 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', |
78 'Class(s(Interface) in s(test.declarations_model), top-level)', | 70 'Class(s(Interface) in s(test.declarations_model), top-level)', |
79 'Class(s(Mixin) in s(test.declarations_model), top-level)', | 71 'Class(s(Mixin) in s(test.declarations_model), top-level)', |
80 'Type(s(Predicate) in s(test.declarations_model), top-level)', | 72 'Type(s(Predicate) in s(test.declarations_model), top-level)', |
81 'Class(s(Superclass) in s(test.declarations_model), top-level)', | 73 'Class(s(Superclass) in s(test.declarations_model), top-level)', |
82 'Class(s(_PrivateClass)' | 74 'Class(s(_PrivateClass)' |
83 ' in s(test.declarations_model), private, top-level)' | 75 ' in s(test.declarations_model), private, top-level)'], |
84 ], lm.declarations.values.where((dm) => dm is TypeMirror).map(stringify), | 76 lm.declarations.values.where((dm) => dm is TypeMirror).map(stringify), |
85 'types'); | 77 'types'); |
86 | 78 |
87 Expect.setEquals([ | 79 Expect.setEquals( |
88 'Class(s(Class) in s(test.declarations_model), top-level)', | 80 ['Class(s(Class) in s(test.declarations_model), top-level)', |
89 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', | 81 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', |
90 'Class(s(Interface) in s(test.declarations_model), top-level)', | 82 'Class(s(Interface) in s(test.declarations_model), top-level)', |
91 'Class(s(Mixin) in s(test.declarations_model), top-level)', | 83 'Class(s(Mixin) in s(test.declarations_model), top-level)', |
92 'Type(s(Predicate) in s(test.declarations_model), top-level)', | 84 'Type(s(Predicate) in s(test.declarations_model), top-level)', |
93 'Class(s(Superclass) in s(test.declarations_model), top-level)', | 85 'Class(s(Superclass) in s(test.declarations_model), top-level)', |
94 'Method(s(libraryGetter)' | 86 'Method(s(libraryGetter)' |
95 ' in s(test.declarations_model), top-level, static, getter)', | 87 ' in s(test.declarations_model), top-level, static, getter)', |
96 'Method(s(libraryMethod)' | 88 'Method(s(libraryMethod)' |
97 ' in s(test.declarations_model), top-level, static)', | 89 ' in s(test.declarations_model), top-level, static)', |
98 'Method(s(librarySetter=)' | 90 'Method(s(librarySetter=)' |
99 ' in s(test.declarations_model), top-level, static, setter)', | 91 ' in s(test.declarations_model), top-level, static, setter)', |
100 'Variable(s(libraryVariable)' | 92 'Variable(s(libraryVariable)' |
101 ' in s(test.declarations_model), top-level, static)' | 93 ' in s(test.declarations_model), top-level, static)'], |
102 ], lm.declarations.values.where((dm) => !dm.isPrivate).map(stringify), | 94 lm.declarations.values.where((dm) => !dm.isPrivate).map(stringify), |
103 'public'); | 95 'public'); |
104 | 96 |
105 Expect.setEquals([ | 97 Expect.setEquals( |
106 'Class(s(Class) in s(test.declarations_model), top-level)', | 98 ['Class(s(Class) in s(test.declarations_model), top-level)', |
107 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', | 99 'Class(s(ConcreteClass) in s(test.declarations_model), top-level)', |
108 'Class(s(Interface) in s(test.declarations_model), top-level)', | 100 'Class(s(Interface) in s(test.declarations_model), top-level)', |
109 'Class(s(Mixin) in s(test.declarations_model), top-level)', | 101 'Class(s(Mixin) in s(test.declarations_model), top-level)', |
110 'Type(s(Predicate) in s(test.declarations_model), top-level)', | 102 'Type(s(Predicate) in s(test.declarations_model), top-level)', |
111 'Class(s(Superclass) in s(test.declarations_model), top-level)', | 103 'Class(s(Superclass) in s(test.declarations_model), top-level)', |
112 'Class(s(_PrivateClass) in s(test.declarations_model), private, top-level)', | 104 'Class(s(_PrivateClass) in s(test.declarations_model), private, top-level)', |
113 'Method(s(_libraryGetter)' | 105 'Method(s(_libraryGetter)' |
114 ' in s(test.declarations_model), private, top-level, static, getter)', | 106 ' in s(test.declarations_model), private, top-level, static, getter)', |
115 'Method(s(_libraryMethod)' | 107 'Method(s(_libraryMethod)' |
116 ' in s(test.declarations_model), private, top-level, static)', | 108 ' in s(test.declarations_model), private, top-level, static)', |
117 'Method(s(_librarySetter=)' | 109 'Method(s(_librarySetter=)' |
118 ' in s(test.declarations_model), private, top-level, static, setter)', | 110 ' in s(test.declarations_model), private, top-level, static, setter)', |
119 'Variable(s(_libraryVariable)' | 111 'Variable(s(_libraryVariable)' |
120 ' in s(test.declarations_model), private, top-level, static)', | 112 ' in s(test.declarations_model), private, top-level, static)', |
121 'Method(s(libraryGetter)' | 113 'Method(s(libraryGetter)' |
122 ' in s(test.declarations_model), top-level, static, getter)', | 114 ' in s(test.declarations_model), top-level, static, getter)', |
123 'Method(s(libraryMethod) in s(test.declarations_model), top-level, static)', | 115 'Method(s(libraryMethod) in s(test.declarations_model), top-level, static)', |
124 'Method(s(librarySetter=)' | 116 'Method(s(librarySetter=)' |
125 ' in s(test.declarations_model), top-level, static, setter)', | 117 ' in s(test.declarations_model), top-level, static, setter)', |
126 'Variable(s(libraryVariable)' | 118 'Variable(s(libraryVariable)' |
127 ' in s(test.declarations_model), top-level, static)' | 119 ' in s(test.declarations_model), top-level, static)'], |
128 ], lm.declarations.values.map(stringify), 'all declarations'); | 120 lm.declarations.values.map(stringify), |
| 121 'all declarations'); |
129 } | 122 } |
OLD | NEW |