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

Side by Side Diff: test/common.dart

Issue 1016913002: pkg/smoke: support latest analyzer version and formatted code (Closed) Base URL: https://github.com/dart-lang/smoke@master
Patch Set: updates Created 5 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
« no previous file with comments | « test/codegen/testing_resolver_utils.dart ('k') | test/common_utils_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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 _checkQuery(res, [#i, #j, #j2, #inc0, #inc1, #inc2]); 250 _checkQuery(res, [#i, #j, #j2, #inc0, #inc1, #inc2]);
251 }); 251 });
252 252
253 test('inherited properties and fields', () { 253 test('inherited properties and fields', () {
254 var options = new smoke.QueryOptions(includeInherited: true); 254 var options = new smoke.QueryOptions(includeInherited: true);
255 var res = smoke.query(D, options); 255 var res = smoke.query(D, options);
256 _checkQuery(res, [#x, #y, #b, #i, #j, #j2, #x2, #i2]); 256 _checkQuery(res, [#x, #y, #b, #i, #j, #j2, #x2, #i2]);
257 }); 257 });
258 258
259 test('inherited fields only', () { 259 test('inherited fields only', () {
260 var options = new smoke.QueryOptions(includeInherited: true, 260 var options = new smoke.QueryOptions(
261 includeProperties: false); 261 includeInherited: true, includeProperties: false);
262 var res = smoke.query(D, options); 262 var res = smoke.query(D, options);
263 _checkQuery(res, [#x, #y, #b, #i, #j]); 263 _checkQuery(res, [#x, #y, #b, #i, #j]);
264 }); 264 });
265 265
266 test('exact annotation', () { 266 test('exact annotation', () {
267 var options = new smoke.QueryOptions(includeInherited: true, 267 var options = new smoke.QueryOptions(
268 withAnnotations: const [a1]); 268 includeInherited: true, withAnnotations: const [a1]);
269 var res = smoke.query(H, options); 269 var res = smoke.query(H, options);
270 _checkQuery(res, [#b, #f, #g]); 270 _checkQuery(res, [#b, #f, #g]);
271 271
272 options = new smoke.QueryOptions(includeInherited: true, 272 options = new smoke.QueryOptions(
273 withAnnotations: const [a2]); 273 includeInherited: true, withAnnotations: const [a2]);
274 res = smoke.query(H, options); 274 res = smoke.query(H, options);
275 _checkQuery(res, [#d, #h]); 275 _checkQuery(res, [#d, #h]);
276 276
277 options = new smoke.QueryOptions(includeInherited: true, 277 options = new smoke.QueryOptions(
278 withAnnotations: const [a1, a2]); 278 includeInherited: true, withAnnotations: const [a1, a2]);
279 res = smoke.query(H, options); 279 res = smoke.query(H, options);
280 _checkQuery(res, [#b, #d, #f, #g, #h]); 280 _checkQuery(res, [#b, #d, #f, #g, #h]);
281 }); 281 });
282 282
283 test('type annotation', () { 283 test('type annotation', () {
284 var options = new smoke.QueryOptions(includeInherited: true, 284 var options = new smoke.QueryOptions(
285 withAnnotations: const [Annot]); 285 includeInherited: true, withAnnotations: const [Annot]);
286 var res = smoke.query(H, options); 286 var res = smoke.query(H, options);
287 _checkQuery(res, [#b, #f, #g, #i]); 287 _checkQuery(res, [#b, #f, #g, #i]);
288 }); 288 });
289 289
290 test('mixed annotations (type and exact)', () { 290 test('mixed annotations (type and exact)', () {
291 var options = new smoke.QueryOptions(includeInherited: true, 291 var options = new smoke.QueryOptions(
292 withAnnotations: const [a2, Annot]); 292 includeInherited: true, withAnnotations: const [a2, Annot]);
293 var res = smoke.query(H, options); 293 var res = smoke.query(H, options);
294 _checkQuery(res, [#b, #d, #f, #g, #h, #i]); 294 _checkQuery(res, [#b, #d, #f, #g, #h, #i]);
295 }); 295 });
296 296
297 test('symbol to name', () { 297 test('symbol to name', () {
298 expect(smoke.symbolToName(#i), 'i'); 298 expect(smoke.symbolToName(#i), 'i');
299 }); 299 });
300 300
301 test('name to symbol', () { 301 test('name to symbol', () {
302 expect(smoke.nameToSymbol('i'), #i); 302 expect(smoke.nameToSymbol('i'), #i);
303 }); 303 });
304 }); 304 });
305 305
306 test('invoke Type instance methods', () { 306 test('invoke Type instance methods', () {
307 var a = new A(); 307 var a = new A();
308 expect( 308 expect(
309 smoke.invoke(a.runtimeType, #toString, []), a.runtimeType.toString()); 309 smoke.invoke(a.runtimeType, #toString, []), a.runtimeType.toString());
310 }); 310 });
311 } 311 }
312 312
313 class A { 313 class A {
314 int i = 42; 314 int i = 42;
315 int j = 44; 315 int j = 44;
316 int get j2 => j; 316 int get j2 => j;
317 void set j2(int v) { j = v; } 317 void set j2(int v) {
318 void inc0() { i++; } 318 j = v;
319 void inc1(int v) { i = i + (v == null ? -10 : v); } 319 }
320 void inc2([int v]) { i = i + (v == null ? -10 : v); } 320 void inc0() {
321 i++;
322 }
323 void inc1(int v) {
324 i = i + (v == null ? -10 : v);
325 }
326 void inc2([int v]) {
327 i = i + (v == null ? -10 : v);
328 }
321 329
322 static int staticValue = 42; 330 static int staticValue = 42;
323 static void staticInc() { staticValue++; } 331 static void staticInc() {
332 staticValue++;
333 }
324 } 334 }
325 335
326 class B { 336 class B {
327 final int f = 3; 337 final int f = 3;
328 int _w; 338 int _w;
329 int get w => _w; 339 int get w => _w;
330 set w(int v) { _w = v; } 340 set w(int v) {
341 _w = v;
342 }
331 343
332 String z; 344 String z;
333 A a; 345 A a;
334 346
335 B(this._w, this.z, this.a); 347 B(this._w, this.z, this.a);
336 } 348 }
337 349
338 class C { 350 class C {
339 int x; 351 int x;
340 String y; 352 String y;
341 B b; 353 B b;
342 354
343 inc(int n) { 355 inc(int n) {
344 x = x + n; 356 x = x + n;
345 } 357 }
346 dec(int n) { 358 dec(int n) {
347 x = x - n; 359 x = x - n;
348 } 360 }
349 361
350 C(this.x, this.y, this.b); 362 C(this.x, this.y, this.b);
351 } 363 }
352 364
353
354 class D extends C with A { 365 class D extends C with A {
355 int get x2 => x; 366 int get x2 => x;
356 int get i2 => i; 367 int get i2 => i;
357 368
358 D(x, y, b) : super(x, y, b); 369 D(x, y, b) : super(x, y, b);
359 } 370 }
360 371
361 class E { 372 class E {
362 set x(int v) { } 373 set x(int v) {}
363 int get y => 1; 374 int get y => 1;
364 375
365 noSuchMethod(i) => y; 376 noSuchMethod(i) => y;
366 } 377 }
367 378
368 class E2 extends E {} 379 class E2 extends E {}
369 380
370 class F { 381 class F {
371 static int staticMethod(A a) => a.i; 382 static int staticMethod(A a) => a.i;
372 } 383 }
373 384
374 class F2 extends F {} 385 class F2 extends F {}
375 386
376 class Annot { const Annot(); } 387 class Annot {
377 class AnnotB extends Annot { const AnnotB(); } 388 const Annot();
378 class AnnotC { const AnnotC({bool named: false}); } 389 }
390 class AnnotB extends Annot {
391 const AnnotB();
392 }
393 class AnnotC {
394 const AnnotC({bool named: false});
395 }
379 const a1 = const Annot(); 396 const a1 = const Annot();
380 const a2 = 32; 397 const a2 = 32;
381 const a3 = const AnnotB(); 398 const a3 = const AnnotB();
382 399
383
384 class G { 400 class G {
385 int a; 401 int a;
386 @a1 int b; 402 @a1 int b;
387 int c; 403 int c;
388 @a2 int d; 404 @a2 int d;
389 } 405 }
390 406
391 class H extends G { 407 class H extends G {
392 int e; 408 int e;
393 @a1 int f; 409 @a1 int f;
394 @a1 int g; 410 @a1 int g;
395 @a2 int h; 411 @a2 int h;
396 @a3 int i; 412 @a3 int i;
397 } 413 }
398 414
399 class K { 415 class K {
400 @AnnotC(named: true) int k; 416 @AnnotC(named: true) int k;
401 @AnnotC() int k2; 417 @AnnotC() int k2;
402 } 418 }
OLDNEW
« no previous file with comments | « test/codegen/testing_resolver_utils.dart ('k') | test/common_utils_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698