Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: pkg/smoke/test/common.dart

Issue 173473002: Adapting observe to use smoke (this is built on top of the previous change that (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/smoke/lib/static.dart ('k') | pkg/smoke/test/static_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Common test code that is run by 3 tests: mirrors_test.dart, 5 /// Common test code that is run by 3 tests: mirrors_test.dart,
6 /// mirrors_used_test.dart, and static_test.dart. 6 /// mirrors_used_test.dart, and static_test.dart.
7 library smoke.test.common; 7 library smoke.test.common;
8 8
9 import 'package:smoke/smoke.dart' as smoke; 9 import 'package:smoke/smoke.dart' as smoke;
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 expect(smoke.hasStaticMethod(C, #inc), isFalse); 133 expect(smoke.hasStaticMethod(C, #inc), isFalse);
134 expect(smoke.hasStaticMethod(D, #inc), isFalse); 134 expect(smoke.hasStaticMethod(D, #inc), isFalse);
135 expect(smoke.hasStaticMethod(D, #inc0), isFalse); 135 expect(smoke.hasStaticMethod(D, #inc0), isFalse);
136 expect(smoke.hasStaticMethod(F, #staticMethod), isTrue); 136 expect(smoke.hasStaticMethod(F, #staticMethod), isTrue);
137 expect(smoke.hasStaticMethod(F2, #staticMethod), isFalse); 137 expect(smoke.hasStaticMethod(F2, #staticMethod), isFalse);
138 }); 138 });
139 139
140 test('get declaration', () { 140 test('get declaration', () {
141 var d = smoke.getDeclaration(B, #a); 141 var d = smoke.getDeclaration(B, #a);
142 expect(d.name, #a); 142 expect(d.name, #a);
143 expect(d.isProperty, isTrue); 143 expect(d.isField, isTrue);
144 expect(d.isProperty, isFalse);
144 expect(d.isMethod, isFalse); 145 expect(d.isMethod, isFalse);
145 expect(d.isFinal, isFalse); 146 expect(d.isFinal, isFalse);
146 expect(d.isStatic, isFalse); 147 expect(d.isStatic, isFalse);
147 expect(d.annotations, []); 148 expect(d.annotations, []);
148 expect(d.type, A); 149 expect(d.type, A);
149 150
150 d = smoke.getDeclaration(B, #w); 151 d = smoke.getDeclaration(B, #w);
151 expect(d.name, #w); 152 expect(d.name, #w);
153 expect(d.isField, isFalse);
152 expect(d.isProperty, isTrue); 154 expect(d.isProperty, isTrue);
153 expect(d.isMethod, isFalse); 155 expect(d.isMethod, isFalse);
154 expect(d.isFinal, isFalse); 156 expect(d.isFinal, isFalse);
155 expect(d.isStatic, isFalse); 157 expect(d.isStatic, isFalse);
156 expect(d.annotations, []); 158 expect(d.annotations, []);
157 expect(d.type, int); 159 expect(d.type, int);
158 160
159 d = smoke.getDeclaration(A, #inc1); 161 d = smoke.getDeclaration(A, #inc1);
160 expect(d.name, #inc1); 162 expect(d.name, #inc1);
163 expect(d.isField, isFalse);
161 expect(d.isProperty, isFalse); 164 expect(d.isProperty, isFalse);
162 expect(d.isMethod, isTrue); 165 expect(d.isMethod, isTrue);
163 expect(d.isFinal, isFalse); 166 expect(d.isFinal, isFalse);
164 expect(d.isStatic, isFalse); 167 expect(d.isStatic, isFalse);
165 expect(d.annotations, []); 168 expect(d.annotations, []);
166 expect(d.type, Function); 169 expect(d.type, Function);
167 170
168 d = smoke.getDeclaration(F, #staticMethod); 171 d = smoke.getDeclaration(F, #staticMethod);
169 expect(d.name, #staticMethod); 172 expect(d.name, #staticMethod);
173 expect(d.isField, isFalse);
170 expect(d.isProperty, isFalse); 174 expect(d.isProperty, isFalse);
171 expect(d.isMethod, isTrue); 175 expect(d.isMethod, isTrue);
172 expect(d.isFinal, isFalse); 176 expect(d.isFinal, isFalse);
173 expect(d.isStatic, isTrue); 177 expect(d.isStatic, isTrue);
174 expect(d.annotations, []); 178 expect(d.annotations, []);
175 expect(d.type, Function); 179 expect(d.type, Function);
176 180
177 d = smoke.getDeclaration(G, #b); 181 d = smoke.getDeclaration(G, #b);
178 expect(d.name, #b); 182 expect(d.name, #b);
179 expect(d.isProperty, isTrue); 183 expect(d.isField, isTrue);
184 expect(d.isProperty, isFalse);
180 expect(d.isMethod, isFalse); 185 expect(d.isMethod, isFalse);
181 expect(d.isFinal, isFalse); 186 expect(d.isFinal, isFalse);
182 expect(d.isStatic, isFalse); 187 expect(d.isStatic, isFalse);
183 expect(d.annotations, [const Annot()]); 188 expect(d.annotations, [const Annot()]);
184 expect(d.type, int); 189 expect(d.type, int);
185 190
186 d = smoke.getDeclaration(G, #d); 191 d = smoke.getDeclaration(G, #d);
187 expect(d.name, #d); 192 expect(d.name, #d);
188 expect(d.isProperty, isTrue); 193 expect(d.isField, isTrue);
194 expect(d.isProperty, isFalse);
189 expect(d.isMethod, isFalse); 195 expect(d.isMethod, isFalse);
190 expect(d.isFinal, isFalse); 196 expect(d.isFinal, isFalse);
191 expect(d.isStatic, isFalse); 197 expect(d.isStatic, isFalse);
192 expect(d.annotations, [32]); 198 expect(d.annotations, [32]);
193 expect(d.type, int); 199 expect(d.type, int);
194 }); 200 });
195 201
196 group('query', () { 202 group('query', () {
197 test('default', () { 203 test('default', () {
198 var options = new smoke.QueryOptions(); 204 var options = new smoke.QueryOptions();
199 var res = smoke.query(A, options); 205 var res = smoke.query(A, options);
200 expect(res.map((e) => e.name), [#i, #j, #j2]); 206 expect(res.map((e) => e.name), [#i, #j, #j2]);
201 }); 207 });
202 208
209 test('only fields', () {
210 var options = new smoke.QueryOptions(includeProperties: false);
211 var res = smoke.query(A, options);
212 expect(res.map((e) => e.name), [#i, #j]);
213 });
214
215 test('only properties', () {
216 var options = new smoke.QueryOptions(includeFields: false);
217 var res = smoke.query(A, options);
218 expect(res.map((e) => e.name), [#j2]);
219 });
220
203 test('properties and methods', () { 221 test('properties and methods', () {
204 var options = new smoke.QueryOptions(includeMethods: true); 222 var options = new smoke.QueryOptions(includeMethods: true);
205 var res = smoke.query(A, options); 223 var res = smoke.query(A, options);
206 expect(res.map((e) => e.name), [#i, #j, #j2, #inc0, #inc1, #inc2]); 224 expect(res.map((e) => e.name), [#i, #j, #j2, #inc0, #inc1, #inc2]);
207 }); 225 });
208 226
209 test('inherited properties', () { 227 test('inherited properties and fields', () {
210 var options = new smoke.QueryOptions(includeInherited: true); 228 var options = new smoke.QueryOptions(includeInherited: true);
211 var res = smoke.query(D, options); 229 var res = smoke.query(D, options);
212 expect(res.map((e) => e.name), [#x, #y, #b, #i, #j, #j2, #x2, #i2]); 230 expect(res.map((e) => e.name), [#x, #y, #b, #i, #j, #j2, #x2, #i2]);
213 }); 231 });
214 232
233 test('inherited fields only', () {
234 var options = new smoke.QueryOptions(includeInherited: true,
235 includeProperties: false);
236 var res = smoke.query(D, options);
237 expect(res.map((e) => e.name), [#x, #y, #b, #i, #j]);
238 });
239
215 test('exact annotation', () { 240 test('exact annotation', () {
216 var options = new smoke.QueryOptions(includeInherited: true, 241 var options = new smoke.QueryOptions(includeInherited: true,
217 withAnnotations: const [a1]); 242 withAnnotations: const [a1]);
218 var res = smoke.query(H, options); 243 var res = smoke.query(H, options);
219 expect(res.map((e) => e.name), [#b, #f, #g]); 244 expect(res.map((e) => e.name), [#b, #f, #g]);
220 245
221 options = new smoke.QueryOptions(includeInherited: true, 246 options = new smoke.QueryOptions(includeInherited: true,
222 withAnnotations: const [a2]); 247 withAnnotations: const [a2]);
223 res = smoke.query(H, options); 248 res = smoke.query(H, options);
224 expect(res.map((e) => e.name), [#d, #h]); 249 expect(res.map((e) => e.name), [#d, #h]);
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 int c; 349 int c;
325 @a2 int d; 350 @a2 int d;
326 } 351 }
327 352
328 class H extends G { 353 class H extends G {
329 int e; 354 int e;
330 @a1 int f; 355 @a1 int f;
331 @a1 int g; 356 @a1 int g;
332 @a2 int h; 357 @a2 int h;
333 } 358 }
OLDNEW
« no previous file with comments | « pkg/smoke/lib/static.dart ('k') | pkg/smoke/test/static_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698