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

Side by Side Diff: pkg/analyzer/test/generated/non_error_resolver_test.dart

Issue 1186033004: Update analyzer to reflect new rules for prefixes. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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) 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 library engine.non_error_resolver_test; 5 library engine.non_error_resolver_test;
6 6
7 import 'package:analyzer/src/generated/ast.dart'; 7 import 'package:analyzer/src/generated/ast.dart';
8 import 'package:analyzer/src/generated/element.dart'; 8 import 'package:analyzer/src/generated/element.dart';
9 import 'package:analyzer/src/generated/engine.dart'; 9 import 'package:analyzer/src/generated/engine.dart';
10 import 'package:analyzer/src/generated/error.dart'; 10 import 'package:analyzer/src/generated/error.dart';
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 F f; 264 F f;
265 main() { 265 main() {
266 F f2 = (() => f()); 266 F f2 = (() => f());
267 } 267 }
268 '''); 268 ''');
269 computeLibrarySourceErrors(source); 269 computeLibrarySourceErrors(source);
270 assertNoErrors(source); 270 assertNoErrors(source);
271 verify([source]); 271 verify([source]);
272 } 272 }
273 273
274 void test_assignment_to_field_with_same_name_as_prefix() {
275 // If p is an import prefix, then within a method body, p = expr should be
276 // considered equivalent to this.p = expr.
277 addNamedSource("/lib.dart", r'''
278 library lib;
279 ''');
280 Source source = addSource(r'''
281 import 'lib.dart' as p;
282 class Base {
283 var p;
284 }
285 class Derived extends Base {
286 f() {
287 p = 0;
288 }
289 }
290 ''');
291 computeLibrarySourceErrors(source);
292 assertErrors(source, [HintCode.UNUSED_IMPORT]);
293 verify([source]);
294 }
295
296 void test_assignmentToFinal_prefixNegate() { 274 void test_assignmentToFinal_prefixNegate() {
297 Source source = addSource(r''' 275 Source source = addSource(r'''
298 f() { 276 f() {
299 final x = 0; 277 final x = 0;
300 -x; 278 -x;
301 }'''); 279 }''');
302 computeLibrarySourceErrors(source); 280 computeLibrarySourceErrors(source);
303 assertNoErrors(source); 281 assertNoErrors(source);
304 verify([source]); 282 verify([source]);
305 } 283 }
(...skipping 4878 matching lines...) Expand 10 before | Expand all | Expand 10 after
5184 class B extends A { 5162 class B extends A {
5185 f() { 5163 f() {
5186 super.m(); 5164 super.m();
5187 } 5165 }
5188 }'''); 5166 }''');
5189 computeLibrarySourceErrors(source); 5167 computeLibrarySourceErrors(source);
5190 assertNoErrors(source); 5168 assertNoErrors(source);
5191 verify([source]); 5169 verify([source]);
5192 } 5170 }
5193 5171
5194 void test_unqualified_invocation_of_method_with_same_name_as_prefix() {
5195 // If p is an import prefix, then within a method body, p() should be
5196 // considered equivalent to this.p().
5197 addNamedSource("/lib.dart", r'''
5198 library lib;
5199 ''');
5200 Source source = addSource(r'''
5201 import 'lib.dart' as p;
5202 class Base {
5203 p() {}
5204 }
5205 class Derived extends Base {
5206 f() {
5207 p();
5208 }
5209 }
5210 ''');
5211 computeLibrarySourceErrors(source);
5212 assertErrors(source, [HintCode.UNUSED_IMPORT]);
5213 verify([source]);
5214 }
5215
5216 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() { 5172 void test_unqualifiedReferenceToNonLocalStaticMember_fromComment_new() {
5217 Source source = addSource(r''' 5173 Source source = addSource(r'''
5218 class A { 5174 class A {
5219 A() {} 5175 A() {}
5220 A.named() {} 5176 A.named() {}
5221 } 5177 }
5222 /// [new A] or [new A.named] 5178 /// [new A] or [new A.named]
5223 main() { 5179 main() {
5224 }'''); 5180 }''');
5225 computeLibrarySourceErrors(source); 5181 computeLibrarySourceErrors(source);
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
5562 reset(); 5518 reset();
5563 } 5519 }
5564 5520
5565 void _check_wrongNumberOfParametersForOperator1(String name) { 5521 void _check_wrongNumberOfParametersForOperator1(String name) {
5566 _check_wrongNumberOfParametersForOperator(name, "a"); 5522 _check_wrongNumberOfParametersForOperator(name, "a");
5567 } 5523 }
5568 5524
5569 CompilationUnit _getResolvedLibraryUnit(Source source) => 5525 CompilationUnit _getResolvedLibraryUnit(Source source) =>
5570 analysisContext.getResolvedCompilationUnit2(source, source); 5526 analysisContext.getResolvedCompilationUnit2(source, source);
5571 } 5527 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698