Chromium Code Reviews| 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/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
| 9 import 'package:analyzer/dart/constant/value.dart'; | 9 import 'package:analyzer/dart/constant/value.dart'; |
| 10 import 'package:analyzer/dart/element/element.dart'; | 10 import 'package:analyzer/dart/element/element.dart'; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 433 } else if (o is PropertyAccess && | 433 } else if (o is PropertyAccess && |
| 434 o.target is PrefixedIdentifier && | 434 o.target is PrefixedIdentifier && |
| 435 r is SimpleIdentifier) { | 435 r is SimpleIdentifier) { |
| 436 // We don't resynthesize property access when it takes the form | 436 // We don't resynthesize property access when it takes the form |
| 437 // `prefixName.className.staticMember`. We just resynthesize a | 437 // `prefixName.className.staticMember`. We just resynthesize a |
| 438 // SimpleIdentifier correctly resolved to the static member. | 438 // SimpleIdentifier correctly resolved to the static member. |
| 439 PrefixedIdentifier oTarget = o.target; | 439 PrefixedIdentifier oTarget = o.target; |
| 440 checkElidablePrefix(oTarget.prefix); | 440 checkElidablePrefix(oTarget.prefix); |
| 441 checkElidablePrefix(oTarget.identifier); | 441 checkElidablePrefix(oTarget.identifier); |
| 442 compareConstAsts(r, o.propertyName, desc); | 442 compareConstAsts(r, o.propertyName, desc); |
| 443 } else if (o is SuperExpression && r is SuperExpression) { | |
| 444 // Nothing to compare. | |
| 443 } else if (o is ThisExpression && r is ThisExpression) { | 445 } else if (o is ThisExpression && r is ThisExpression) { |
| 444 // Nothing to compare. | 446 // Nothing to compare. |
| 445 } else if (o is NullLiteral) { | 447 } else if (o is NullLiteral) { |
| 446 expect(r, new isInstanceOf<NullLiteral>(), reason: desc); | 448 expect(r, new isInstanceOf<NullLiteral>(), reason: desc); |
| 447 } else if (o is BooleanLiteral && r is BooleanLiteral) { | 449 } else if (o is BooleanLiteral && r is BooleanLiteral) { |
| 448 expect(r.value, o.value, reason: desc); | 450 expect(r.value, o.value, reason: desc); |
| 449 } else if (o is IntegerLiteral && r is IntegerLiteral) { | 451 } else if (o is IntegerLiteral && r is IntegerLiteral) { |
| 450 expect(r.value, o.value, reason: desc); | 452 expect(r.value, o.value, reason: desc); |
| 451 } else if (o is DoubleLiteral && r is DoubleLiteral) { | 453 } else if (o is DoubleLiteral && r is DoubleLiteral) { |
| 452 if (r.value != null && | 454 if (r.value != null && |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 688 expect(resynthesized.name, original.name); | 690 expect(resynthesized.name, original.name); |
| 689 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); | 691 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); |
| 690 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); | 692 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); |
| 691 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); | 693 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); |
| 692 expect(resynthesized.documentationComment, original.documentationComment, | 694 expect(resynthesized.documentationComment, original.documentationComment, |
| 693 reason: desc); | 695 reason: desc); |
| 694 compareMetadata(resynthesized.metadata, original.metadata, desc); | 696 compareMetadata(resynthesized.metadata, original.metadata, desc); |
| 695 | 697 |
| 696 // Validate modifiers. | 698 // Validate modifiers. |
| 697 for (Modifier modifier in Modifier.values) { | 699 for (Modifier modifier in Modifier.values) { |
| 700 // There is no way to know this by looking at declarations. | |
| 701 if (modifier == Modifier.REFERENCES_SUPER) { | |
|
Paul Berry
2017/01/29 14:28:02
We can't safely do this. The modifier REFERENCES_
scheglov
2017/01/29 18:05:15
Done.
| |
| 702 continue; | |
| 703 } | |
| 698 bool got = _hasModifier(resynthesized, modifier); | 704 bool got = _hasModifier(resynthesized, modifier); |
| 699 bool want = _hasModifier(original, modifier); | 705 bool want = _hasModifier(original, modifier); |
| 700 expect(got, want, | 706 expect(got, want, |
| 701 reason: 'Mismatch in $desc.$modifier: got $got, want $want'); | 707 reason: 'Mismatch in $desc.$modifier: got $got, want $want'); |
| 702 } | 708 } |
| 703 | 709 |
| 704 // Validate members. | 710 // Validate members. |
| 705 if (oImpl is Member) { | 711 if (oImpl is Member) { |
| 706 expect(rImpl, new isInstanceOf<Member>(), reason: desc); | 712 expect(rImpl, new isInstanceOf<Member>(), reason: desc); |
| 707 } else { | 713 } else { |
| (...skipping 1647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2355 | 2361 |
| 2356 test_const_topLevel_prefix() { | 2362 test_const_topLevel_prefix() { |
| 2357 checkLibrary(r''' | 2363 checkLibrary(r''' |
| 2358 const vNotEqual = 1 != 2; | 2364 const vNotEqual = 1 != 2; |
| 2359 const vNot = !true; | 2365 const vNot = !true; |
| 2360 const vNegate = -1; | 2366 const vNegate = -1; |
| 2361 const vComplement = ~1; | 2367 const vComplement = ~1; |
| 2362 '''); | 2368 '''); |
| 2363 } | 2369 } |
| 2364 | 2370 |
| 2371 test_const_topLevel_super() { | |
| 2372 checkLibrary(r''' | |
| 2373 const vSuper = super; | |
| 2374 '''); | |
| 2375 } | |
| 2376 | |
| 2365 test_const_topLevel_this() { | 2377 test_const_topLevel_this() { |
| 2366 checkLibrary(r''' | 2378 checkLibrary(r''' |
| 2367 const vThis = this; | 2379 const vThis = this; |
| 2368 '''); | 2380 '''); |
| 2369 } | 2381 } |
| 2370 | 2382 |
| 2371 test_const_topLevel_typedList() { | 2383 test_const_topLevel_typedList() { |
| 2372 checkLibrary(r''' | 2384 checkLibrary(r''' |
| 2373 const vNull = const <Null>[]; | 2385 const vNull = const <Null>[]; |
| 2374 const vDynamic = const <dynamic>[1, 2, 3]; | 2386 const vDynamic = const <dynamic>[1, 2, 3]; |
| (...skipping 2438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4813 } | 4825 } |
| 4814 | 4826 |
| 4815 test_typedef_type_parameters_f_bound_simple() { | 4827 test_typedef_type_parameters_f_bound_simple() { |
| 4816 checkLibrary('typedef U F<T extends U, U>(T t);'); | 4828 checkLibrary('typedef U F<T extends U, U>(T t);'); |
| 4817 } | 4829 } |
| 4818 | 4830 |
| 4819 test_typedefs() { | 4831 test_typedefs() { |
| 4820 checkLibrary('f() {} g() {}'); | 4832 checkLibrary('f() {} g() {}'); |
| 4821 } | 4833 } |
| 4822 | 4834 |
| 4835 test_unresolved_annotation_instanceCreation_argument_super() { | |
| 4836 checkLibrary( | |
| 4837 ''' | |
| 4838 class A { | |
| 4839 const A(_); | |
| 4840 } | |
| 4841 | |
| 4842 @A(super) | |
| 4843 class C {} | |
| 4844 ''', | |
| 4845 allowErrors: true); | |
| 4846 } | |
| 4847 | |
| 4823 test_unresolved_annotation_instanceCreation_argument_this() { | 4848 test_unresolved_annotation_instanceCreation_argument_this() { |
| 4824 checkLibrary( | 4849 checkLibrary( |
| 4825 ''' | 4850 ''' |
| 4826 class A { | 4851 class A { |
| 4827 const A(_); | 4852 const A(_); |
| 4828 } | 4853 } |
| 4829 | 4854 |
| 4830 @A(this) | 4855 @A(this) |
| 4831 class C {} | 4856 class C {} |
| 4832 ''', | 4857 ''', |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5054 fail('Unexpectedly tried to get unlinked summary for $uri'); | 5079 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 5055 } | 5080 } |
| 5056 return serializedUnit; | 5081 return serializedUnit; |
| 5057 } | 5082 } |
| 5058 | 5083 |
| 5059 @override | 5084 @override |
| 5060 bool hasLibrarySummary(String uri) { | 5085 bool hasLibrarySummary(String uri) { |
| 5061 return true; | 5086 return true; |
| 5062 } | 5087 } |
| 5063 } | 5088 } |
| OLD | NEW |