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

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

Issue 2689343003: Fixes for referenced names computing. (Closed)
Patch Set: Created 3 years, 10 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';
(...skipping 10 matching lines...) Expand all
21 Set<String> names = _computeReferencedNames(''' 21 Set<String> names = _computeReferencedNames('''
22 class U { 22 class U {
23 U.named(A a, B b) { 23 U.named(A a, B b) {
24 C c = null; 24 C c = null;
25 } 25 }
26 } 26 }
27 '''); 27 ''');
28 expect(names, unorderedEquals(['A', 'B', 'C'])); 28 expect(names, unorderedEquals(['A', 'B', 'C']));
29 } 29 }
30 30
31 test_class_constructor_parameters() {
32 Set<String> names = _computeReferencedNames('''
33 class U {
34 U(A a) {
35 a;
36 b;
37 }
38 }
39 ''');
40 expect(names, unorderedEquals(['A', 'b']));
41 }
42
31 test_class_field() { 43 test_class_field() {
32 Set<String> names = _computeReferencedNames(''' 44 Set<String> names = _computeReferencedNames('''
33 class U { 45 class U {
34 A f = new B(); 46 A f = new B();
35 } 47 }
36 '''); 48 ''');
37 expect(names, unorderedEquals(['A', 'B'])); 49 expect(names, unorderedEquals(['A', 'B']));
38 } 50 }
39 51
40 test_class_getter() { 52 test_class_getter() {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 class U { 125 class U {
114 m(A a) { 126 m(A a) {
115 a; 127 a;
116 b; 128 b;
117 } 129 }
118 } 130 }
119 '''); 131 ''');
120 expect(names, unorderedEquals(['A', 'b'])); 132 expect(names, unorderedEquals(['A', 'b']));
121 } 133 }
122 134
135 test_class_method_parameters_dontHideNamedExpressionName() {
136 Set<String> names = _computeReferencedNames('''
137 main() {
138 var p;
139 new C(p: p);
140 }
141 ''');
142 expect(names, unorderedEquals(['C', 'p']));
143 }
144
123 test_class_method_typeParameters() { 145 test_class_method_typeParameters() {
124 Set<String> names = _computeReferencedNames(''' 146 Set<String> names = _computeReferencedNames('''
125 class U { 147 class U {
126 A m<T>(B b, T t) { 148 A m<T>(B b, T t) {
127 C c = 0; 149 C c = 0;
128 } 150 }
129 } 151 }
130 '''); 152 ''');
131 expect(names, unorderedEquals(['A', 'B', 'C'])); 153 expect(names, unorderedEquals(['A', 'B', 'C']));
132 } 154 }
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 } 402 }
381 '''); 403 ''');
382 expect(names, unorderedEquals(['A', 'B', 'C'])); 404 expect(names, unorderedEquals(['A', 'B', 'C']));
383 } 405 }
384 406
385 Set<String> _computeReferencedNames(String code) { 407 Set<String> _computeReferencedNames(String code) {
386 CompilationUnit unit = parseCompilationUnit2(code); 408 CompilationUnit unit = parseCompilationUnit2(code);
387 return computeReferencedNames(unit); 409 return computeReferencedNames(unit);
388 } 410 }
389 } 411 }
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