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:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 10 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 * Tests may set this to `false` to indicate that resynthesized elements | 62 * Tests may set this to `false` to indicate that resynthesized elements |
63 * should not be compare with elements created using AnalysisContext. | 63 * should not be compare with elements created using AnalysisContext. |
64 */ | 64 */ |
65 bool shouldCompareLibraryElements = true; | 65 bool shouldCompareLibraryElements = true; |
66 | 66 |
67 /** | 67 /** |
68 * Return `true` if resynthesizing should be done is strong mode. | 68 * Return `true` if resynthesizing should be done is strong mode. |
69 */ | 69 */ |
70 bool get isStrongMode; | 70 bool get isStrongMode; |
71 | 71 |
72 /** | |
73 * Return `true` if shared front-end is used. | |
74 */ | |
75 bool get isSharedFrontEnd => false; | |
76 | |
72 void addLibrary(String uri) { | 77 void addLibrary(String uri) { |
73 otherLibrarySources.add(context.sourceFactory.forUri(uri)); | 78 otherLibrarySources.add(context.sourceFactory.forUri(uri)); |
74 } | 79 } |
75 | 80 |
76 Source addLibrarySource(String filePath, String contents) { | 81 Source addLibrarySource(String filePath, String contents) { |
77 Source source = addSource(filePath, contents); | 82 Source source = addSource(filePath, contents); |
78 otherLibrarySources.add(source); | 83 otherLibrarySources.add(source); |
79 return source; | 84 return source; |
80 } | 85 } |
81 | 86 |
(...skipping 3510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3592 } | 3597 } |
3593 | 3598 |
3594 test_const_length_ofClassConstField() async { | 3599 test_const_length_ofClassConstField() async { |
3595 var library = await checkLibrary(r''' | 3600 var library = await checkLibrary(r''' |
3596 class C { | 3601 class C { |
3597 static const String F = ''; | 3602 static const String F = ''; |
3598 } | 3603 } |
3599 const int v = C.F.length; | 3604 const int v = C.F.length; |
3600 '''); | 3605 '''); |
3601 if (isStrongMode) { | 3606 if (isStrongMode) { |
3602 checkElementText(library, r''' | 3607 if (isSharedFrontEnd) { |
3608 checkElementText(library, r''' | |
3603 class C { | 3609 class C { |
3604 static const String F = ''; | 3610 static const String F = ''; |
3605 } | 3611 } |
3612 const int v = | |
3613 F/*location: test.dart;C;F?*/. | |
Paul Berry
2017/07/18 18:00:14
I'm ok with not resynthesizing identifiers associa
scheglov
2017/07/18 19:01:11
Done.
| |
3614 length/*location: dart:core;String;length?*/; | |
3615 '''); | |
3616 } else { | |
3617 checkElementText(library, r''' | |
3618 class C { | |
3619 static const String F = ''; | |
3620 } | |
3606 const int v = | 3621 const int v = |
3607 C/*location: test.dart;C*/. | 3622 C/*location: test.dart;C*/. |
3608 F/*location: test.dart;C;F?*/. | 3623 F/*location: test.dart;C;F?*/. |
3609 length/*location: dart:core;String;length?*/; | 3624 length/*location: dart:core;String;length?*/; |
3610 '''); | 3625 '''); |
3626 } | |
3611 } else { | 3627 } else { |
3612 checkElementText(library, r''' | 3628 checkElementText(library, r''' |
3613 class C { | 3629 class C { |
3614 static const String F = ''; | 3630 static const String F = ''; |
3615 } | 3631 } |
3616 const int v = | 3632 const int v = |
3617 C/*location: test.dart;C*/. | 3633 C/*location: test.dart;C*/. |
3618 F/*location: test.dart;C;F?*/. | 3634 F/*location: test.dart;C;F?*/. |
3619 length/*location: dart:core;String;length?*/; | 3635 length/*location: dart:core;String;length?*/; |
3620 '''); | 3636 '''); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3679 length/*location: dart:core;String;length?*/; | 3695 length/*location: dart:core;String;length?*/; |
3680 '''); | 3696 '''); |
3681 } | 3697 } |
3682 } | 3698 } |
3683 | 3699 |
3684 test_const_length_ofStringLiteral() async { | 3700 test_const_length_ofStringLiteral() async { |
3685 var library = await checkLibrary(r''' | 3701 var library = await checkLibrary(r''' |
3686 const v = 'abc'.length; | 3702 const v = 'abc'.length; |
3687 '''); | 3703 '''); |
3688 if (isStrongMode) { | 3704 if (isStrongMode) { |
3689 checkElementText(library, r''' | 3705 if (isSharedFrontEnd) { |
3706 checkElementText(library, r''' | |
3707 const int v = 'abc'. | |
3708 length/*location: dart:core;String;length?*/; | |
3709 '''); | |
3710 } else { | |
3711 checkElementText(library, r''' | |
3690 const dynamic v/*error: instanceGetter*/ = 'abc'. | 3712 const dynamic v/*error: instanceGetter*/ = 'abc'. |
3691 length/*location: dart:core;String;length?*/; | 3713 length/*location: dart:core;String;length?*/; |
3692 '''); | 3714 '''); |
3715 } | |
3693 } else { | 3716 } else { |
3694 checkElementText(library, r''' | 3717 checkElementText(library, r''' |
3695 const dynamic v = 'abc'. | 3718 const dynamic v = 'abc'. |
3696 length/*location: dart:core;String;length?*/; | 3719 length/*location: dart:core;String;length?*/; |
3697 '''); | 3720 '''); |
3698 } | 3721 } |
3699 } | 3722 } |
3700 | 3723 |
3701 test_const_length_ofTopLevelVariable() async { | 3724 test_const_length_ofTopLevelVariable() async { |
3702 var library = await checkLibrary(r''' | 3725 var library = await checkLibrary(r''' |
3703 const String S = 'abc'; | 3726 const String S = 'abc'; |
3704 const v = S.length; | 3727 const v = S.length; |
3705 '''); | 3728 '''); |
3706 if (isStrongMode) { | 3729 if (isStrongMode) { |
3707 checkElementText(library, r''' | 3730 if (isSharedFrontEnd) { |
3731 checkElementText(library, r''' | |
3732 const String S = 'abc'; | |
3733 const int v = | |
3734 S/*location: test.dart;S?*/. | |
3735 length/*location: dart:core;String;length?*/; | |
3736 '''); | |
3737 } else { | |
3738 checkElementText(library, r''' | |
3708 const String S = 'abc'; | 3739 const String S = 'abc'; |
3709 const dynamic v/*error: instanceGetter*/ = | 3740 const dynamic v/*error: instanceGetter*/ = |
3710 S/*location: test.dart;S?*/. | 3741 S/*location: test.dart;S?*/. |
3711 length/*location: dart:core;String;length?*/; | 3742 length/*location: dart:core;String;length?*/; |
3712 '''); | 3743 '''); |
3744 } | |
3713 } else { | 3745 } else { |
3714 checkElementText(library, r''' | 3746 checkElementText(library, r''' |
3715 const String S = 'abc'; | 3747 const String S = 'abc'; |
3716 const dynamic v = | 3748 const dynamic v = |
3717 S/*location: test.dart;S?*/. | 3749 S/*location: test.dart;S?*/. |
3718 length/*location: dart:core;String;length?*/; | 3750 length/*location: dart:core;String;length?*/; |
3719 '''); | 3751 '''); |
3720 } | 3752 } |
3721 } | 3753 } |
3722 | 3754 |
(...skipping 9428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
13151 fail('Unexpectedly tried to get unlinked summary for $uri'); | 13183 fail('Unexpectedly tried to get unlinked summary for $uri'); |
13152 } | 13184 } |
13153 return serializedUnit; | 13185 return serializedUnit; |
13154 } | 13186 } |
13155 | 13187 |
13156 @override | 13188 @override |
13157 bool hasLibrarySummary(String uri) { | 13189 bool hasLibrarySummary(String uri) { |
13158 return true; | 13190 return true; |
13159 } | 13191 } |
13160 } | 13192 } |
OLD | NEW |