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

Side by Side Diff: pkg/front_end/test/src/incremental/file_state_test.dart

Issue 2928393004: Add FileState.hasMixin/hasMixinLibrary properties. (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:front_end/memory_file_system.dart'; 7 import 'package:front_end/memory_file_system.dart';
8 import 'package:front_end/src/fasta/translate_uri.dart'; 8 import 'package:front_end/src/fasta/translate_uri.dart';
9 import 'package:front_end/src/incremental/file_state.dart'; 9 import 'package:front_end/src/incremental/file_state.dart';
10 import 'package:test/test.dart'; 10 import 'package:test/test.dart';
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 expect(export_.combinators[1].names, unorderedEquals(['C'])); 277 expect(export_.combinators[1].names, unorderedEquals(['C']));
278 expect(export_.combinators[2].isShow, isTrue); 278 expect(export_.combinators[2].isShow, isTrue);
279 expect(export_.combinators[2].names, unorderedEquals(['A', 'D'])); 279 expect(export_.combinators[2].names, unorderedEquals(['A', 'D']));
280 expect(export_.isExposed('A'), isTrue); 280 expect(export_.isExposed('A'), isTrue);
281 expect(export_.isExposed('B'), isFalse); 281 expect(export_.isExposed('B'), isFalse);
282 expect(export_.isExposed('C'), isFalse); 282 expect(export_.isExposed('C'), isFalse);
283 expect(export_.isExposed('D'), isTrue); 283 expect(export_.isExposed('D'), isTrue);
284 } 284 }
285 } 285 }
286 286
287 test_hasMixin_false() async {
288 writeFile(
289 '/a.dart',
290 r'''
291 class A {}
292 class B extends Object with A {}
293 ''');
294 var uri = writeFile(
295 '/test.dart',
296 r'''
297 import 'a.dart';
298 class T1 extends A {}
299 class T2 extends B {}
300 ''');
301 FileState file = await fsState.getFile(uri);
302 expect(file.hasMixin, isFalse);
303 }
304
305 test_hasMixin_true() async {
306 var uri = writeFile(
307 '/test.dart',
308 r'''
309 class A {}
310 class B extends Object with A {}
311 ''');
312 FileState file = await fsState.getFile(uri);
313 expect(file.hasMixin, isTrue);
314 }
315
316 test_hasMixinLibrary_false() async {
317 var partUri = writeFile(
318 '/part.dart',
319 r'''
320 part of test;
321 class A {}
322 ''');
323 var libUri = writeFile(
324 '/test.dart',
325 r'''
326 library test;
327 part 'part.dart';
328 class B extends A {}
329 ''');
330
331 FileState part = await fsState.getFile(partUri);
332 FileState lib = await fsState.getFile(libUri);
333
334 expect(part.hasMixin, isFalse);
335 expect(lib.hasMixin, isFalse);
336 expect(lib.hasMixinLibrary, isFalse);
337 }
338
339 test_hasMixinLibrary_true_inDefiningUnit() async {
340 var partUri = writeFile(
341 '/part.dart',
342 r'''
343 part of test;
344 class A {}
345 ''');
346 var libUri = writeFile(
347 '/test.dart',
348 r'''
349 library test;
350 part 'part.dart';
351 class B extends Object with A {}
352 ''');
353
354 FileState part = await fsState.getFile(partUri);
355 FileState lib = await fsState.getFile(libUri);
356
357 expect(part.hasMixin, isFalse);
358 expect(lib.hasMixin, isTrue);
359 expect(lib.hasMixinLibrary, isTrue);
360 }
361
362 test_hasMixinLibrary_true_inPart() async {
363 var partUri = writeFile(
364 '/part.dart',
365 r'''
366 part of test;
367 class A {}
368 class B extends Object with A {}
ahe 2017/06/12 19:22:03 Consider adding a test for a named mixin applicati
scheglov 2017/06/12 19:43:19 Done.
369 ''');
370 var libUri = writeFile(
371 '/test.dart',
372 r'''
373 library test;
374 part 'part.dart';
375 class C {}
376 ''');
377
378 FileState part = await fsState.getFile(partUri);
379 FileState lib = await fsState.getFile(libUri);
380
381 expect(part.hasMixin, isTrue);
382 expect(lib.hasMixin, isFalse);
383 expect(lib.hasMixinLibrary, isTrue);
384 }
385
287 test_newFileListener() async { 386 test_newFileListener() async {
288 var a = writeFile('/a.dart', ''); 387 var a = writeFile('/a.dart', '');
289 var b = writeFile('/b.dart', ''); 388 var b = writeFile('/b.dart', '');
290 var c = writeFile( 389 var c = writeFile(
291 '/c.dart', 390 '/c.dart',
292 r''' 391 r'''
293 import 'a.dart'; 392 import 'a.dart';
294 '''); 393 ''');
295 394
296 FileState cFile = await fsState.getFile(c); 395 FileState cFile = await fsState.getFile(c);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 Uri _writeFileDirectives(String path, 490 Uri _writeFileDirectives(String path,
392 {List<String> imports: const [], List<String> exports: const []}) { 491 {List<String> imports: const [], List<String> exports: const []}) {
393 return writeFile( 492 return writeFile(
394 path, 493 path,
395 ''' 494 '''
396 ${imports.map((uri) => 'import "$uri";').join('\n')} 495 ${imports.map((uri) => 'import "$uri";').join('\n')}
397 ${exports.map((uri) => 'export "$uri";').join('\n')} 496 ${exports.map((uri) => 'export "$uri";').join('\n')}
398 '''); 497 ''');
399 } 498 }
400 } 499 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698