OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.context.context_test; | 5 library test.src.context.context_test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analyzer/file_system/memory_file_system.dart'; | 9 import 'package:analyzer/file_system/memory_file_system.dart'; |
10 import 'package:analyzer/src/cancelable_future.dart'; | 10 import 'package:analyzer/src/cancelable_future.dart'; |
(...skipping 792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 expect(context.analysisOptions, isNotNull); | 803 expect(context.analysisOptions, isNotNull); |
804 } | 804 } |
805 | 805 |
806 void test_getContents_fromSource() { | 806 void test_getContents_fromSource() { |
807 String content = "library lib;"; | 807 String content = "library lib;"; |
808 TimestampedData<String> contents = | 808 TimestampedData<String> contents = |
809 context.getContents(new TestSource('/test.dart', content)); | 809 context.getContents(new TestSource('/test.dart', content)); |
810 expect(contents.data.toString(), content); | 810 expect(contents.data.toString(), content); |
811 } | 811 } |
812 | 812 |
| 813 void test_getContents_notOverridden() { |
| 814 String content = "library lib;"; |
| 815 Source source = new TestSource('/test.dart', content); |
| 816 context.setContents(source, "part of lib;"); |
| 817 context.setContents(source, null); |
| 818 TimestampedData<String> contents = context.getContents(source); |
| 819 expect(contents.data.toString(), content); |
| 820 } |
| 821 |
813 void test_getContents_overridden() { | 822 void test_getContents_overridden() { |
814 String content = "library lib;"; | 823 String content = "library lib;"; |
815 Source source = new TestSource(); | 824 Source source = new TestSource(); |
816 context.setContents(source, content); | 825 context.setContents(source, content); |
817 TimestampedData<String> contents = context.getContents(source); | 826 TimestampedData<String> contents = context.getContents(source); |
818 expect(contents.data.toString(), content); | 827 expect(contents.data.toString(), content); |
819 } | 828 } |
820 | |
821 void test_getContents_unoverridden() { | |
822 String content = "library lib;"; | |
823 Source source = new TestSource('/test.dart', content); | |
824 context.setContents(source, "part of lib;"); | |
825 context.setContents(source, null); | |
826 TimestampedData<String> contents = context.getContents(source); | |
827 expect(contents.data.toString(), content); | |
828 } | |
829 | 829 |
830 void test_getDeclaredVariables() { | 830 void test_getDeclaredVariables() { |
831 expect(context.declaredVariables, isNotNull); | 831 expect(context.declaredVariables, isNotNull); |
832 } | 832 } |
833 | 833 |
834 void test_getElement() { | 834 void test_getElement() { |
835 LibraryElement core = | 835 LibraryElement core = |
836 context.computeLibraryElement(sourceFactory.forUri("dart:core")); | 836 context.computeLibraryElement(sourceFactory.forUri("dart:core")); |
837 expect(core, isNotNull); | 837 expect(core, isNotNull); |
838 ClassElement classObject = | 838 ClassElement classObject = |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1039 addSource( | 1039 addSource( |
1040 "/a.dart", | 1040 "/a.dart", |
1041 r''' | 1041 r''' |
1042 import 'dart:html'; | 1042 import 'dart:html'; |
1043 '''); | 1043 '''); |
1044 Source source = addSource( | 1044 Source source = addSource( |
1045 "/test.dart", | 1045 "/test.dart", |
1046 r''' | 1046 r''' |
1047 import 'a.dart'; | 1047 import 'a.dart'; |
1048 main() {}'''); | 1048 main() {}'''); |
1049 context.computeLibraryElement(source); | 1049 _analyzeAll_assertFinished(); |
1050 sources = context.launchableClientLibrarySources; | 1050 sources = context.launchableClientLibrarySources; |
1051 expect(sources, unorderedEquals([source])); | 1051 expect(sources, unorderedEquals([source])); |
1052 } | 1052 } |
1053 | 1053 |
1054 void test_getLaunchableClientLibrarySources_importsHtml_implicitly2() { | 1054 void test_getLaunchableClientLibrarySources_importsHtml_implicitly2() { |
1055 List<Source> sources = context.launchableClientLibrarySources; | 1055 List<Source> sources = context.launchableClientLibrarySources; |
1056 expect(sources, isEmpty); | 1056 expect(sources, isEmpty); |
1057 addSource( | 1057 addSource( |
1058 "/a.dart", | 1058 "/a.dart", |
1059 r''' | 1059 r''' |
1060 export 'dart:html'; | 1060 export 'dart:html'; |
1061 '''); | 1061 '''); |
1062 Source source = addSource( | 1062 Source source = addSource( |
1063 "/test.dart", | 1063 "/test.dart", |
1064 r''' | 1064 r''' |
1065 import 'a.dart'; | 1065 import 'a.dart'; |
1066 main() {}'''); | 1066 main() {}'''); |
1067 context.computeLibraryElement(source); | 1067 _analyzeAll_assertFinished(); |
1068 sources = context.launchableClientLibrarySources; | 1068 sources = context.launchableClientLibrarySources; |
1069 expect(sources, unorderedEquals([source])); | 1069 expect(sources, unorderedEquals([source])); |
1070 } | 1070 } |
1071 | 1071 |
1072 void test_getLaunchableServerLibrarySources() { | 1072 void test_getLaunchableServerLibrarySources() { |
1073 expect(context.launchableServerLibrarySources, isEmpty); | 1073 expect(context.launchableServerLibrarySources, isEmpty); |
1074 Source source = addSource("/test.dart", "main() {}"); | 1074 Source source = addSource("/test.dart", "main() {}"); |
1075 context.computeLibraryElement(source); | 1075 context.computeLibraryElement(source); |
1076 expect(context.launchableServerLibrarySources, unorderedEquals([source])); | 1076 expect(context.launchableServerLibrarySources, unorderedEquals([source])); |
1077 } | 1077 } |
1078 | 1078 |
1079 void test_getLaunchableServerLibrarySources_importsHtml_explicitly() { | 1079 void test_getLaunchableServerLibrarySources_importsHtml_explicitly() { |
1080 Source source = addSource( | 1080 Source source = addSource( |
1081 "/test.dart", | 1081 "/test.dart", |
1082 r''' | 1082 r''' |
1083 import 'dart:html'; | 1083 import 'dart:html'; |
1084 main() {} | 1084 main() {} |
1085 '''); | 1085 '''); |
1086 context.computeLibraryElement(source); | 1086 context.computeLibraryElement(source); |
1087 expect(context.launchableServerLibrarySources, isEmpty); | 1087 expect(context.launchableServerLibrarySources, isEmpty); |
1088 } | 1088 } |
1089 | 1089 |
1090 void test_getLaunchableServerLibrarySources_importsHtml_implicitly() { | 1090 void test_getLaunchableServerLibrarySources_importsHtml_implicitly() { |
1091 addSource( | 1091 addSource( |
1092 "/imports_html.dart", | 1092 "/imports_html.dart", |
1093 r''' | 1093 r''' |
1094 import 'dart:html'; | 1094 import 'dart:html'; |
1095 '''); | 1095 '''); |
1096 Source source = addSource( | 1096 addSource( |
1097 "/test.dart", | 1097 "/test.dart", |
1098 r''' | 1098 r''' |
1099 import 'imports_html.dart'; | 1099 import 'imports_html.dart'; |
1100 main() {}'''); | 1100 main() {}'''); |
1101 context.computeLibraryElement(source); | 1101 _analyzeAll_assertFinished(); |
1102 expect(context.launchableServerLibrarySources, isEmpty); | 1102 expect(context.launchableServerLibrarySources, isEmpty); |
1103 } | 1103 } |
1104 | 1104 |
1105 void test_getLaunchableServerLibrarySources_noMain() { | 1105 void test_getLaunchableServerLibrarySources_noMain() { |
1106 Source source = addSource("/test.dart", ''); | 1106 Source source = addSource("/test.dart", ''); |
1107 context.computeLibraryElement(source); | 1107 context.computeLibraryElement(source); |
1108 expect(context.launchableServerLibrarySources, isEmpty); | 1108 expect(context.launchableServerLibrarySources, isEmpty); |
1109 } | 1109 } |
1110 | 1110 |
1111 void test_getLibrariesContaining() { | 1111 void test_getLibrariesContaining() { |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2586 } | 2586 } |
2587 } | 2587 } |
2588 | 2588 |
2589 class _AnalysisContextImplTest_test_applyChanges_removeContainer | 2589 class _AnalysisContextImplTest_test_applyChanges_removeContainer |
2590 implements SourceContainer { | 2590 implements SourceContainer { |
2591 Source libB; | 2591 Source libB; |
2592 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); | 2592 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); |
2593 @override | 2593 @override |
2594 bool contains(Source source) => source == libB; | 2594 bool contains(Source source) => source == libB; |
2595 } | 2595 } |
OLD | NEW |