| 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // TODO(scheglov) prefixes cannot be resynthesized | 669 // TODO(scheglov) prefixes cannot be resynthesized |
| 670 return; | 670 return; |
| 671 } | 671 } |
| 672 expect(original, isNotNull); | 672 expect(original, isNotNull); |
| 673 expect(resynthesized, isNotNull, reason: desc); | 673 expect(resynthesized, isNotNull, reason: desc); |
| 674 if (rImpl is DefaultParameterElementImpl && oImpl is ParameterElementImpl) { | 674 if (rImpl is DefaultParameterElementImpl && oImpl is ParameterElementImpl) { |
| 675 // This is ok provided the resynthesized parameter element doesn't have | 675 // This is ok provided the resynthesized parameter element doesn't have |
| 676 // any evaluation result. | 676 // any evaluation result. |
| 677 expect(rImpl.evaluationResult, isNull); | 677 expect(rImpl.evaluationResult, isNull); |
| 678 } else { | 678 } else { |
| 679 expect(rImpl.runtimeType, oImpl.runtimeType); | 679 Type rRuntimeType; |
| 680 if (rImpl is FunctionElementImpl) { |
| 681 rRuntimeType = FunctionElementImpl; |
| 682 } else { |
| 683 rRuntimeType = rImpl.runtimeType; |
| 684 } |
| 685 expect(rRuntimeType, oImpl.runtimeType); |
| 680 } | 686 } |
| 681 expect(resynthesized.kind, original.kind); | 687 expect(resynthesized.kind, original.kind); |
| 682 expect(resynthesized.location, original.location, reason: desc); | 688 expect(resynthesized.location, original.location, reason: desc); |
| 683 expect(resynthesized.name, original.name); | 689 expect(resynthesized.name, original.name); |
| 684 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); | 690 expect(resynthesized.nameOffset, original.nameOffset, reason: desc); |
| 685 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); | 691 expect(rImpl.codeOffset, oImpl.codeOffset, reason: desc); |
| 686 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); | 692 expect(rImpl.codeLength, oImpl.codeLength, reason: desc); |
| 687 expect(resynthesized.documentationComment, original.documentationComment, | 693 expect(resynthesized.documentationComment, original.documentationComment, |
| 688 reason: desc); | 694 reason: desc); |
| 689 expect(resynthesized.docRange, original.docRange, reason: desc); | 695 expect(resynthesized.docRange, original.docRange, reason: desc); |
| (...skipping 2719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3409 Stream s; | 3415 Stream s; |
| 3410 '''); | 3416 '''); |
| 3411 } | 3417 } |
| 3412 | 3418 |
| 3413 test_imports() { | 3419 test_imports() { |
| 3414 addLibrarySource('/a.dart', 'library a; class C {}'); | 3420 addLibrarySource('/a.dart', 'library a; class C {}'); |
| 3415 addLibrarySource('/b.dart', 'library b; class D {}'); | 3421 addLibrarySource('/b.dart', 'library b; class D {}'); |
| 3416 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); | 3422 checkLibrary('import "a.dart"; import "b.dart"; C c; D d;'); |
| 3417 } | 3423 } |
| 3418 | 3424 |
| 3419 void test_inferedType_usesSyntheticFunctionType_functionTypedParam() { | |
| 3420 checkLibrary(''' | |
| 3421 int f(int x(String y)) => null; | |
| 3422 String g(int x(String y)) => null; | |
| 3423 var v = [f, g]; | |
| 3424 '''); | |
| 3425 } | |
| 3426 | |
| 3427 test_inferred_function_type_for_variable_in_generic_function() { | 3425 test_inferred_function_type_for_variable_in_generic_function() { |
| 3428 // In the code below, `x` has an inferred type of `() => int`, with 2 | 3426 // In the code below, `x` has an inferred type of `() => int`, with 2 |
| 3429 // (unused) type parameters from the enclosing top level function. | 3427 // (unused) type parameters from the enclosing top level function. |
| 3430 checkLibrary(''' | 3428 checkLibrary(''' |
| 3431 f<U, V>() { | 3429 f<U, V>() { |
| 3432 var x = () => 0; | 3430 var x = () => 0; |
| 3433 } | 3431 } |
| 3434 '''); | 3432 '''); |
| 3435 } | 3433 } |
| 3436 | 3434 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3567 f({void g(int x, void h())}) => null; | 3565 f({void g(int x, void h())}) => null; |
| 3568 var v = f(g: (x, y) {}); | 3566 var v = f(g: (x, y) {}); |
| 3569 '''); | 3567 '''); |
| 3570 } | 3568 } |
| 3571 | 3569 |
| 3572 test_inferred_type_refers_to_setter_function_typed_parameter_type() { | 3570 test_inferred_type_refers_to_setter_function_typed_parameter_type() { |
| 3573 checkLibrary('class C extends D { void set f(g) {} }' | 3571 checkLibrary('class C extends D { void set f(g) {} }' |
| 3574 ' abstract class D { void set f(int g(String s)); }'); | 3572 ' abstract class D { void set f(int g(String s)); }'); |
| 3575 } | 3573 } |
| 3576 | 3574 |
| 3575 void test_inferredType_usesSyntheticFunctionType_functionTypedParam() { |
| 3576 checkLibrary(''' |
| 3577 int f(int x(String y)) => null; |
| 3578 String g(int x(String y)) => null; |
| 3579 var v = [f, g]; |
| 3580 '''); |
| 3581 } |
| 3582 |
| 3577 test_initializer_executable_with_return_type_from_closure() { | 3583 test_initializer_executable_with_return_type_from_closure() { |
| 3578 checkLibrary('var v = () => 0;'); | 3584 checkLibrary('var v = () => 0;'); |
| 3579 } | 3585 } |
| 3580 | 3586 |
| 3581 test_initializer_executable_with_return_type_from_closure_field() { | 3587 test_initializer_executable_with_return_type_from_closure_field() { |
| 3582 checkLibrary(''' | 3588 checkLibrary(''' |
| 3583 class C { | 3589 class C { |
| 3584 var v = () => 0; | 3590 var v = () => 0; |
| 3585 } | 3591 } |
| 3586 '''); | 3592 '''); |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4606 fail('Unexpectedly tried to get unlinked summary for $uri'); | 4612 fail('Unexpectedly tried to get unlinked summary for $uri'); |
| 4607 } | 4613 } |
| 4608 return serializedUnit; | 4614 return serializedUnit; |
| 4609 } | 4615 } |
| 4610 | 4616 |
| 4611 @override | 4617 @override |
| 4612 bool hasLibrarySummary(String uri) { | 4618 bool hasLibrarySummary(String uri) { |
| 4613 return true; | 4619 return true; |
| 4614 } | 4620 } |
| 4615 } | 4621 } |
| OLD | NEW |