OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.declaration_resolver_test; | 5 library engine.declaration_resolver_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/element/element.dart'; | 8 import 'package:analyzer/dart/element/element.dart'; |
9 import 'package:analyzer/src/dart/ast/ast.dart'; | 9 import 'package:analyzer/src/dart/ast/ast.dart'; |
10 import 'package:analyzer/src/dart/ast/utilities.dart'; | 10 import 'package:analyzer/src/dart/ast/utilities.dart'; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 _findSimpleIdentifier(unit, code, 'zzz(_)').staticElement; | 375 _findSimpleIdentifier(unit, code, 'zzz(_)').staticElement; |
376 expect(setterElement.isSetter, isTrue); | 376 expect(setterElement.isSetter, isTrue); |
377 // re-resolve | 377 // re-resolve |
378 CompilationUnit unit2 = _cloneResolveUnit(unit); | 378 CompilationUnit unit2 = _cloneResolveUnit(unit); |
379 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz(_)'); | 379 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz(_)'); |
380 expect(getterName.staticElement, same(setterElement)); | 380 expect(getterName.staticElement, same(setterElement)); |
381 } | 381 } |
382 | 382 |
383 void test_invalid_functionDeclaration_getter_inFunction() { | 383 void test_invalid_functionDeclaration_getter_inFunction() { |
384 String code = r''' | 384 String code = r''' |
385 main() { | 385 var v = (() { |
386 int get zzz => 42; | 386 main() { |
387 } | 387 int get zzz => 42; |
| 388 } |
| 389 }); |
388 '''; | 390 '''; |
389 CompilationUnit unit = resolveSource(code); | 391 CompilationUnit unit = resolveSource(code); |
390 FunctionElement getterElement = | 392 FunctionElement getterElement = |
391 _findSimpleIdentifier(unit, code, 'zzz =>').staticElement; | 393 _findSimpleIdentifier(unit, code, 'zzz =>').staticElement; |
392 // re-resolve | 394 // re-resolve |
393 CompilationUnit unit2 = _cloneResolveUnit(unit); | 395 CompilationUnit unit2 = _cloneResolveUnit(unit); |
394 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz =>'); | 396 SimpleIdentifier getterName = _findSimpleIdentifier(unit2, code, 'zzz =>'); |
395 expect(getterName.staticElement, same(getterElement)); | 397 expect(getterName.staticElement, same(getterElement)); |
396 } | 398 } |
397 | 399 |
398 void test_invalid_functionDeclaration_setter_inFunction() { | 400 void test_invalid_functionDeclaration_setter_inFunction() { |
399 String code = r''' | 401 String code = r''' |
400 main() { | 402 var v = (() { |
401 set zzz(x) {} | 403 main() { |
402 } | 404 set zzz(x) {} |
| 405 } |
| 406 }); |
403 '''; | 407 '''; |
404 CompilationUnit unit = resolveSource(code); | 408 CompilationUnit unit = resolveSource(code); |
405 FunctionElement setterElement = | 409 FunctionElement setterElement = |
406 _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement; | 410 _findSimpleIdentifier(unit, code, 'zzz(x)').staticElement; |
407 // re-resolve | 411 // re-resolve |
408 CompilationUnit unit2 = _cloneResolveUnit(unit); | 412 CompilationUnit unit2 = _cloneResolveUnit(unit); |
409 SimpleIdentifier setterName = _findSimpleIdentifier(unit2, code, 'zzz(x)'); | 413 SimpleIdentifier setterName = _findSimpleIdentifier(unit2, code, 'zzz(x)'); |
410 expect(setterName.staticElement, same(setterElement)); | 414 expect(setterName.staticElement, same(setterElement)); |
411 } | 415 } |
412 | 416 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 expect(element.type.toString(), "<T>(T, T) → T"); | 622 expect(element.type.toString(), "<T>(T, T) → T"); |
619 expect(t.element, same(tElement)); | 623 expect(t.element, same(tElement)); |
620 | 624 |
621 // re-resolve | 625 // re-resolve |
622 CompilationUnit unit2 = _cloneResolveUnit(unit); | 626 CompilationUnit unit2 = _cloneResolveUnit(unit); |
623 node = _findSimpleIdentifier(unit2, code, 'max').parent; | 627 node = _findSimpleIdentifier(unit2, code, 'max').parent; |
624 t = node.typeParameters.typeParameters[0]; | 628 t = node.typeParameters.typeParameters[0]; |
625 expect(t.element, same(tElement)); | 629 expect(t.element, same(tElement)); |
626 } | 630 } |
627 } | 631 } |
OLD | NEW |