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 test.src.serialization.elements_test; | 5 library test.src.serialization.elements_test; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/constant/value.dart'; | 8 import 'package:analyzer/dart/constant/value.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 expect(r.period, isNull, reason: desc); | 535 expect(r.period, isNull, reason: desc); |
536 expect(r.constructorName, isNull, reason: desc); | 536 expect(r.constructorName, isNull, reason: desc); |
537 } | 537 } |
538 } else { | 538 } else { |
539 compareConstAsts(r.name, o.name, desc); | 539 compareConstAsts(r.name, o.name, desc); |
540 expect(r.period?.lexeme, o.period?.lexeme, reason: desc); | 540 expect(r.period?.lexeme, o.period?.lexeme, reason: desc); |
541 compareConstAsts(r.constructorName, o.constructorName, desc); | 541 compareConstAsts(r.constructorName, o.constructorName, desc); |
542 } | 542 } |
543 compareConstAstLists( | 543 compareConstAstLists( |
544 r.arguments?.arguments, o.arguments?.arguments, desc); | 544 r.arguments?.arguments, o.arguments?.arguments, desc); |
545 Element expectedElement = o.element; | 545 compareElements(r.element, o.element, desc); |
546 if (oName is PrefixedIdentifier && | |
547 o.constructorName != null && | |
548 o.element != null) { | |
549 // Due to dartbug.com/25706, [o.element] incorrectly points to the | |
550 // class rather than the named constructor. Hack around this. | |
551 // TODO(paulberry): when dartbug.com/25706 is fixed, remove this. | |
552 expectedElement = (expectedElement as ClassElement) | |
553 .getNamedConstructor(o.constructorName.name); | |
554 expect(expectedElement, isNotNull, reason: desc); | |
555 } | |
556 compareElements(r.element, expectedElement, desc); | |
557 // elementAnnotation should be null; it is only used in the full AST. | 546 // elementAnnotation should be null; it is only used in the full AST. |
558 expect(o.elementAnnotation, isNull); | 547 expect(o.elementAnnotation, isNull); |
559 expect(r.elementAnnotation, isNull); | 548 expect(r.elementAnnotation, isNull); |
560 } else { | 549 } else { |
561 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); | 550 fail('Not implemented for ${r.runtimeType} vs. ${o.runtimeType}'); |
562 } | 551 } |
563 } | 552 } |
564 } | 553 } |
565 | 554 |
566 void compareConstructorElements(ConstructorElement resynthesized, | 555 void compareConstructorElements(ConstructorElement resynthesized, |
(...skipping 3918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4485 } | 4474 } |
4486 | 4475 |
4487 test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() { | 4476 test_unresolved_annotation_prefixedNamedConstructorCall_badPrefix() { |
4488 checkLibrary('@foo.bar.baz() class C {}'); | 4477 checkLibrary('@foo.bar.baz() class C {}'); |
4489 } | 4478 } |
4490 | 4479 |
4491 test_unresolved_annotation_prefixedNamedConstructorCall_noClass() { | 4480 test_unresolved_annotation_prefixedNamedConstructorCall_noClass() { |
4492 checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}'); | 4481 checkLibrary('import "dart:async" as foo; @foo.bar.baz() class C {}'); |
4493 } | 4482 } |
4494 | 4483 |
4495 @failingTest // See dartbug.com/25706 | |
4496 test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() { | 4484 test_unresolved_annotation_prefixedNamedConstructorCall_noConstructor() { |
4497 checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}'); | 4485 checkLibrary('import "dart:async" as foo; @foo.Future.bar() class C {}'); |
4498 } | 4486 } |
4499 | 4487 |
4500 test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() { | 4488 test_unresolved_annotation_prefixedUnnamedConstructorCall_badPrefix() { |
4501 checkLibrary('@foo.bar() class C {}'); | 4489 checkLibrary('@foo.bar() class C {}'); |
4502 } | 4490 } |
4503 | 4491 |
4504 test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() { | 4492 test_unresolved_annotation_prefixedUnnamedConstructorCall_noClass() { |
4505 checkLibrary('import "dart:async" as foo; @foo.bar() class C {}'); | 4493 checkLibrary('import "dart:async" as foo; @foo.bar() class C {}'); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4677 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4665 fail('Unexpectedly tried to get unlinked summary for $uri'); |
4678 } | 4666 } |
4679 return serializedUnit; | 4667 return serializedUnit; |
4680 } | 4668 } |
4681 | 4669 |
4682 @override | 4670 @override |
4683 bool hasLibrarySummary(String uri) { | 4671 bool hasLibrarySummary(String uri) { |
4684 return true; | 4672 return true; |
4685 } | 4673 } |
4686 } | 4674 } |
OLD | NEW |