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

Side by Side Diff: pkg/analyzer/test/src/dart/analysis/referenced_names_test.dart

Issue 2961773002: Compute subtyped names. (Closed)
Patch Set: Created 3 years, 5 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 | « pkg/analyzer/lib/src/dart/analysis/referenced_names.dart ('k') | no next file » | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/src/dart/analysis/referenced_names.dart'; 6 import 'package:analyzer/src/dart/analysis/referenced_names.dart';
7 import 'package:test/test.dart'; 7 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; 8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9 9
10 import '../../../generated/parser_test.dart'; 10 import '../../../generated/parser_test.dart';
11 11
12 main() { 12 main() {
13 defineReflectiveSuite(() { 13 defineReflectiveSuite(() {
14 defineReflectiveTests(ReferencedNamesBuilderTest); 14 defineReflectiveTests(ComputeReferencedNamesTest);
15 defineReflectiveTests(ComputeSubtypedNamesTest);
15 }); 16 });
16 } 17 }
17 18
18 @reflectiveTest 19 @reflectiveTest
19 class ReferencedNamesBuilderTest extends ParserTestCase { 20 class ComputeReferencedNamesTest extends ParserTestCase {
20 test_class_constructor() { 21 test_class_constructor() {
21 Set<String> names = _computeReferencedNames(''' 22 Set<String> names = _computeReferencedNames('''
22 class U { 23 class U {
23 U.named(A a, B b) { 24 U.named(A a, B b) {
24 C c = null; 25 C c = null;
25 } 26 }
26 } 27 }
27 '''); 28 ''');
28 expect(names, unorderedEquals(['A', 'B', 'C'])); 29 expect(names, unorderedEquals(['A', 'B', 'C']));
29 } 30 }
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 } 403 }
403 '''); 404 ''');
404 expect(names, unorderedEquals(['A', 'B', 'C'])); 405 expect(names, unorderedEquals(['A', 'B', 'C']));
405 } 406 }
406 407
407 Set<String> _computeReferencedNames(String code) { 408 Set<String> _computeReferencedNames(String code) {
408 CompilationUnit unit = parseCompilationUnit2(code); 409 CompilationUnit unit = parseCompilationUnit2(code);
409 return computeReferencedNames(unit); 410 return computeReferencedNames(unit);
410 } 411 }
411 } 412 }
413
414 @reflectiveTest
415 class ComputeSubtypedNamesTest extends ParserTestCase {
416 void test_prefixed() {
417 Set<String> names = _computeSubtypedNames('''
418 import 'lib.dart' as p;
419 class X extends p.A with p.B implements p.C {}
420 ''');
421 expect(names, unorderedEquals(['A', 'B', 'C']));
422 }
423
424 void test_typeArguments() {
425 Set<String> names = _computeSubtypedNames('''
426 import 'lib.dart';
427 class X extends A<B> {}
428 ''');
429 expect(names, unorderedEquals(['A']));
430 }
431
432 void test_unprefixed() {
433 Set<String> names = _computeSubtypedNames('''
434 import 'lib.dart';
435 class X extends A {}
436 class Y extends A with B {}
437 class Z implements A, B, C {}
438 ''');
439 expect(names, unorderedEquals(['A', 'B', 'C']));
440 }
441
442 Set<String> _computeSubtypedNames(String code) {
443 CompilationUnit unit = parseCompilationUnit2(code);
444 return computeSubtypedNames(unit);
445 }
446 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/analysis/referenced_names.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698