| 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 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/constant/value.dart'; | 10 import 'package:analyzer/dart/constant/value.dart'; |
| (...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 ElementImpl oImpl = getActualElement(original, desc); | 651 ElementImpl oImpl = getActualElement(original, desc); |
| 652 if (oImpl == null && rImpl == null) { | 652 if (oImpl == null && rImpl == null) { |
| 653 return; | 653 return; |
| 654 } | 654 } |
| 655 if (oImpl is PrefixElement) { | 655 if (oImpl is PrefixElement) { |
| 656 // TODO(scheglov) prefixes cannot be resynthesized | 656 // TODO(scheglov) prefixes cannot be resynthesized |
| 657 return; | 657 return; |
| 658 } | 658 } |
| 659 expect(original, isNotNull); | 659 expect(original, isNotNull); |
| 660 expect(resynthesized, isNotNull, reason: desc); | 660 expect(resynthesized, isNotNull, reason: desc); |
| 661 expect(rImpl.runtimeType, oImpl.runtimeType); | 661 if (rImpl is DefaultParameterElementImpl && oImpl is ParameterElementImpl) { |
| 662 // This is ok provided the resynthesized parameter element doesn't have |
| 663 // any evaluation result. |
| 664 expect(rImpl.evaluationResult, isNull); |
| 665 } else { |
| 666 expect(rImpl.runtimeType, oImpl.runtimeType); |
| 667 } |
| 662 expect(resynthesized.kind, original.kind); | 668 expect(resynthesized.kind, original.kind); |
| 663 expect(resynthesized.location, original.location, reason: desc); | 669 expect(resynthesized.location, original.location, reason: desc); |
| 664 expect(resynthesized.name, original.name); | 670 expect(resynthesized.name, original.name); |
| 665 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); | 671 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); |
| 666 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); | 672 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); |
| 667 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); | 673 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); |
| 668 expect(resynthesized.documentationComment, original.documentationComment, | 674 expect(resynthesized.documentationComment, original.documentationComment, |
| 669 reason: desc); | 675 reason: desc); |
| 670 expect(resynthesized.docRange, original.docRange, reason: desc); | 676 expect(resynthesized.docRange, original.docRange, reason: desc); |
| 671 compareMetadata(resynthesized.metadata, original.metadata, desc); | 677 compareMetadata(resynthesized.metadata, original.metadata, desc); |
| (...skipping 2547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3219 Stream s; | 3225 Stream s; |
| 3220 '''); | 3226 '''); |
| 3221 } | 3227 } |
| 3222 | 3228 |
| 3223 test_imports() { | 3229 test_imports() { |
| 3224 addLibrarySource('/a.dart', 'library a; class C {}'); | 3230 addLibrarySource('/a.dart', 'library a; class C {}'); |
| 3225 addLibrarySource('/b.dart', 'library b; class D {}'); | 3231 addLibrarySource('/b.dart', 'library b; class D {}'); |
| 3226 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); | 3232 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); |
| 3227 } | 3233 } |
| 3228 | 3234 |
| 3235 void test_inferedType_usesSyntheticFunctionType_functionTypedParam() { |
| 3236 checkLibrary(''' |
| 3237 int f(int x(String y)) => null; |
| 3238 String g(int x(String y)) => null; |
| 3239 var v = [f, g]; |
| 3240 '''); |
| 3241 } |
| 3242 |
| 3229 test_inferred_function_type_for_variable_in_generic_function() { | 3243 test_inferred_function_type_for_variable_in_generic_function() { |
| 3230 // In the code below, `x` has an inferred type of `() => int`, with 2 | 3244 // In the code below, `x` has an inferred type of `() => int`, with 2 |
| 3231 // (unused) type parameters from the enclosing top level function. | 3245 // (unused) type parameters from the enclosing top level function. |
| 3232 checkLibrary(''' | 3246 checkLibrary(''' |
| 3233 f<U, V>() { | 3247 f<U, V>() { |
| 3234 var x = () => 0; | 3248 var x = () => 0; |
| 3235 } | 3249 } |
| 3236 '''); | 3250 '''); |
| 3237 } | 3251 } |
| 3238 | 3252 |
| (...skipping 1169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4408 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4422 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 4409 } | 4423 } |
| 4410 return serializedUnit; | 4424 return serializedUnit; |
| 4411 } | 4425 } |
| 4412 | 4426 |
| 4413 @override | 4427 @override |
| 4414 bool hasLibrarySummary(String uri) { | 4428 bool hasLibrarySummary(String uri) { |
| 4415 return true; | 4429 return true; |
| 4416 } | 4430 } |
| 4417 } | 4431 } |
| OLD | NEW |