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.task.dart_test; | 5 library test.src.task.dart_test; |
6 | 6 |
7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
9 import 'package:analyzer/src/generated/constant.dart'; | 9 import 'package:analyzer/src/generated/constant.dart'; |
10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
(...skipping 22 matching lines...) Expand all Loading... | |
33 runReflectiveTests(BuildDirectiveElementsTaskTest); | 33 runReflectiveTests(BuildDirectiveElementsTaskTest); |
34 runReflectiveTests(BuildEnumMemberElementsTaskTest); | 34 runReflectiveTests(BuildEnumMemberElementsTaskTest); |
35 runReflectiveTests(BuildSourceExportClosureTaskTest); | 35 runReflectiveTests(BuildSourceExportClosureTaskTest); |
36 runReflectiveTests(BuildSourceImportExportClosureTaskTest); | 36 runReflectiveTests(BuildSourceImportExportClosureTaskTest); |
37 runReflectiveTests(BuildExportNamespaceTaskTest); | 37 runReflectiveTests(BuildExportNamespaceTaskTest); |
38 runReflectiveTests(BuildLibraryElementTaskTest); | 38 runReflectiveTests(BuildLibraryElementTaskTest); |
39 runReflectiveTests(BuildPublicNamespaceTaskTest); | 39 runReflectiveTests(BuildPublicNamespaceTaskTest); |
40 runReflectiveTests(BuildTypeProviderTaskTest); | 40 runReflectiveTests(BuildTypeProviderTaskTest); |
41 runReflectiveTests(ComputeConstantDependenciesTaskTest); | 41 runReflectiveTests(ComputeConstantDependenciesTaskTest); |
42 runReflectiveTests(ComputeConstantValueTaskTest); | 42 runReflectiveTests(ComputeConstantValueTaskTest); |
43 runReflectiveTests(ComputeInferableStaticVariableDependenciesTaskTest); | |
43 runReflectiveTests(ContainingLibrariesTaskTest); | 44 runReflectiveTests(ContainingLibrariesTaskTest); |
44 runReflectiveTests(DartErrorsTaskTest); | 45 runReflectiveTests(DartErrorsTaskTest); |
45 runReflectiveTests(EvaluateUnitConstantsTaskTest); | 46 runReflectiveTests(EvaluateUnitConstantsTaskTest); |
46 runReflectiveTests(GatherUsedImportedElementsTaskTest); | 47 runReflectiveTests(GatherUsedImportedElementsTaskTest); |
47 runReflectiveTests(GatherUsedLocalElementsTaskTest); | 48 runReflectiveTests(GatherUsedLocalElementsTaskTest); |
48 runReflectiveTests(GenerateHintsTaskTest); | 49 runReflectiveTests(GenerateHintsTaskTest); |
49 runReflectiveTests(LibraryErrorsReadyTaskTest); | 50 runReflectiveTests(LibraryErrorsReadyTaskTest); |
50 runReflectiveTests(LibraryUnitErrorsTaskTest); | 51 runReflectiveTests(LibraryUnitErrorsTaskTest); |
51 runReflectiveTests(ParseDartTaskTest); | 52 runReflectiveTests(ParseDartTaskTest); |
52 runReflectiveTests(PartiallyResolveReferencesTaskTest); | 53 runReflectiveTests(PartiallyResolveReferencesTaskTest); |
53 runReflectiveTests(ResolveUnitTypeNamesTaskTest); | 54 runReflectiveTests(ResolveUnitTypeNamesTaskTest); |
54 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); | 55 runReflectiveTests(ResolveLibraryTypeNamesTaskTest); |
55 runReflectiveTests(ResolveReferencesTaskTest); | 56 runReflectiveTests(ResolveReferencesTaskTest); |
56 runReflectiveTests(ResolveVariableReferencesTaskTest); | 57 runReflectiveTests(ResolveVariableReferencesTaskTest); |
57 runReflectiveTests(ScanDartTaskTest); | 58 runReflectiveTests(ScanDartTaskTest); |
58 runReflectiveTests(VerifyUnitTaskTest); | 59 runReflectiveTests(VerifyUnitTaskTest); |
59 } | 60 } |
60 | 61 |
61 @reflectiveTest | 62 @reflectiveTest |
62 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { | 63 class BuildCompilationUnitElementTaskTest extends _AbstractDartTaskTest { |
63 Source source; | 64 Source source; |
64 LibrarySpecificUnit target; | 65 LibrarySpecificUnit target; |
65 | 66 |
66 /** | |
67 * Enable strong mode in the current analysis context. | |
68 */ | |
69 void enableStrongMode() { | |
70 AnalysisOptionsImpl options = context.analysisOptions; | |
71 options.strongMode = true; | |
72 context.analysisOptions = options; | |
73 } | |
74 | |
75 test_buildInputs() { | 67 test_buildInputs() { |
76 LibrarySpecificUnit target = | 68 LibrarySpecificUnit target = |
77 new LibrarySpecificUnit(emptySource, emptySource); | 69 new LibrarySpecificUnit(emptySource, emptySource); |
78 Map<String, TaskInput> inputs = | 70 Map<String, TaskInput> inputs = |
79 BuildCompilationUnitElementTask.buildInputs(target); | 71 BuildCompilationUnitElementTask.buildInputs(target); |
80 expect(inputs, isNotNull); | 72 expect(inputs, isNotNull); |
81 expect( | 73 expect( |
82 inputs.keys, | 74 inputs.keys, |
83 unorderedEquals( | 75 unorderedEquals( |
84 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); | 76 [BuildCompilationUnitElementTask.PARSED_UNIT_INPUT_NAME])); |
(...skipping 20 matching lines...) Expand all Loading... | |
105 new BuildCompilationUnitElementTask(null, emptySource); | 97 new BuildCompilationUnitElementTask(null, emptySource); |
106 expect(task.description, isNotNull); | 98 expect(task.description, isNotNull); |
107 } | 99 } |
108 | 100 |
109 test_descriptor() { | 101 test_descriptor() { |
110 TaskDescriptor descriptor = BuildCompilationUnitElementTask.DESCRIPTOR; | 102 TaskDescriptor descriptor = BuildCompilationUnitElementTask.DESCRIPTOR; |
111 expect(descriptor, isNotNull); | 103 expect(descriptor, isNotNull); |
112 } | 104 } |
113 | 105 |
114 test_perform_find_constants_strong() { | 106 test_perform_find_constants_strong() { |
115 enableStrongMode(); | |
116 _performBuildTask(''' | 107 _performBuildTask(''' |
117 const x = 1; | 108 const x = 1; |
118 class C { | 109 class C { |
119 static const y = 1; | 110 static const y = 1; |
120 const C([p = 1]); | 111 const C([p = 1]); |
121 } | 112 } |
122 @x | 113 @x |
123 f() { | 114 f() { |
124 const z = 1; | 115 const z = 1; |
125 } | 116 } |
126 '''); | 117 '''); |
127 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 118 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
128 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; | 119 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; |
129 Annotation annotation = unit.declarations | 120 Annotation annotation = unit.declarations |
130 .firstWhere((m) => m is FunctionDeclaration) | 121 .firstWhere((m) => m is FunctionDeclaration) |
131 .metadata[0]; | 122 .metadata[0]; |
132 List<ConstantEvaluationTarget> expectedConstants = [ | 123 List<ConstantEvaluationTarget> expectedConstants = [ |
133 unitElement.accessors.firstWhere((e) => e.isGetter).variable, | 124 unitElement.accessors.firstWhere((e) => e.isGetter).variable, |
134 unitElement.types[0].fields[0], | 125 unitElement.types[0].fields[0], |
135 unitElement.functions[0].localVariables[0], | 126 unitElement.functions[0].localVariables[0], |
136 unitElement.types[0].constructors[0], | 127 unitElement.types[0].constructors[0], |
137 new ConstantEvaluationTarget_Annotation( | 128 new ConstantEvaluationTarget_Annotation( |
138 context, source, source, annotation), | 129 context, source, source, annotation), |
139 unitElement.types[0].constructors[0].parameters[0] | 130 unitElement.types[0].constructors[0].parameters[0] |
140 ]; | 131 ]; |
141 expect(outputs[CLASSES_IN_UNIT], hasLength(1)); | |
142 expect( | 132 expect( |
143 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); | 133 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); |
144 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); | |
145 } | 134 } |
146 | 135 |
147 test_perform_find_constants_weak() { | 136 test_perform_find_constants_weak() { |
Paul Berry
2015/08/27 18:56:08
It looks like this test is now the same as the pre
Brian Wilkerson
2015/08/27 20:43:54
Done
| |
148 _performBuildTask(''' | 137 _performBuildTask(''' |
149 const x = 1; | 138 const x = 1; |
150 class C { | 139 class C { |
151 static const y = 1; | 140 static const y = 1; |
152 const C([p = 1]); | 141 const C([p = 1]); |
153 } | 142 } |
154 @x | 143 @x |
155 f() { | 144 f() { |
156 const z = 1; | 145 const z = 1; |
157 } | 146 } |
158 '''); | 147 '''); |
159 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 148 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
160 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; | 149 CompilationUnitElement unitElement = outputs[COMPILATION_UNIT_ELEMENT]; |
161 Annotation annotation = unit.declarations | 150 Annotation annotation = unit.declarations |
162 .firstWhere((m) => m is FunctionDeclaration) | 151 .firstWhere((m) => m is FunctionDeclaration) |
163 .metadata[0]; | 152 .metadata[0]; |
164 List<ConstantEvaluationTarget> expectedConstants = [ | 153 List<ConstantEvaluationTarget> expectedConstants = [ |
165 unitElement.accessors.firstWhere((e) => e.isGetter).variable, | 154 unitElement.accessors.firstWhere((e) => e.isGetter).variable, |
166 unitElement.types[0].fields[0], | 155 unitElement.types[0].fields[0], |
167 unitElement.functions[0].localVariables[0], | 156 unitElement.functions[0].localVariables[0], |
168 unitElement.types[0].constructors[0], | 157 unitElement.types[0].constructors[0], |
169 new ConstantEvaluationTarget_Annotation( | 158 new ConstantEvaluationTarget_Annotation( |
170 context, source, source, annotation), | 159 context, source, source, annotation), |
171 unitElement.types[0].constructors[0].parameters[0] | 160 unitElement.types[0].constructors[0].parameters[0] |
172 ]; | 161 ]; |
173 expect(outputs[CLASSES_IN_UNIT], hasLength(0)); | |
174 expect( | 162 expect( |
175 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); | 163 outputs[COMPILATION_UNIT_CONSTANTS].toSet(), expectedConstants.toSet()); |
176 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); | |
177 } | 164 } |
178 | 165 |
179 test_perform_library_strong() { | 166 test_perform_library_strong() { |
180 enableStrongMode(); | |
181 _performBuildTask(r''' | 167 _performBuildTask(r''' |
182 library lib; | 168 library lib; |
183 import 'lib2.dart'; | 169 import 'lib2.dart'; |
184 export 'lib3.dart'; | 170 export 'lib3.dart'; |
185 part 'part.dart'; | 171 part 'part.dart'; |
186 final x = ''; | 172 final x = ''; |
187 class A { | 173 class A { |
188 static final y = 0; | 174 static final y = 0; |
189 } | 175 } |
190 class B = Object with A; | 176 class B = Object with A; |
191 '''); | 177 '''); |
192 expect(outputs, hasLength(5)); | 178 expect(outputs, hasLength(3)); |
193 expect(outputs[CLASSES_IN_UNIT], hasLength(2)); | |
194 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); | 179 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); |
195 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); | 180 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
196 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); | |
197 expect(outputs[RESOLVED_UNIT1], isNotNull); | 181 expect(outputs[RESOLVED_UNIT1], isNotNull); |
198 } | 182 } |
199 | 183 |
200 test_perform_library_weak() { | 184 test_perform_library_weak() { |
Paul Berry
2015/08/27 18:56:08
Same issue here.
Brian Wilkerson
2015/08/27 20:43:54
Done
| |
201 _performBuildTask(r''' | 185 _performBuildTask(r''' |
202 library lib; | 186 library lib; |
203 import 'lib2.dart'; | 187 import 'lib2.dart'; |
204 export 'lib3.dart'; | 188 export 'lib3.dart'; |
205 part 'part.dart'; | 189 part 'part.dart'; |
206 final x = ''; | 190 final x = ''; |
207 class A { | 191 class A { |
208 static final y = 0; | 192 static final y = 0; |
209 } | 193 } |
210 class B = Object with A; | 194 class B = Object with A; |
211 '''); | 195 '''); |
212 expect(outputs, hasLength(5)); | 196 expect(outputs, hasLength(3)); |
213 expect(outputs[CLASSES_IN_UNIT], hasLength(0)); | |
214 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); | 197 expect(outputs[COMPILATION_UNIT_CONSTANTS], isNotNull); |
215 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); | 198 expect(outputs[COMPILATION_UNIT_ELEMENT], isNotNull); |
216 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); | |
217 expect(outputs[RESOLVED_UNIT1], isNotNull); | 199 expect(outputs[RESOLVED_UNIT1], isNotNull); |
218 } | 200 } |
219 | 201 |
220 test_perform_reuseElement() { | 202 test_perform_reuseElement() { |
221 _performBuildTask(r''' | 203 _performBuildTask(r''' |
222 library lib; | 204 library lib; |
223 class A {} | 205 class A {} |
224 class B = Object with A; | 206 class B = Object with A; |
225 '''); | 207 '''); |
226 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 208 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1549 computeResult(librarySpecificUnit, RESOLVED_UNIT1); | 1531 computeResult(librarySpecificUnit, RESOLVED_UNIT1); |
1550 CompilationUnit unit = outputs[RESOLVED_UNIT1]; | 1532 CompilationUnit unit = outputs[RESOLVED_UNIT1]; |
1551 return unit; | 1533 return unit; |
1552 } | 1534 } |
1553 | 1535 |
1554 CompilationUnit _resolveUnit(String content) => | 1536 CompilationUnit _resolveUnit(String content) => |
1555 _resolveSource(newSource('/test.dart', content)); | 1537 _resolveSource(newSource('/test.dart', content)); |
1556 } | 1538 } |
1557 | 1539 |
1558 @reflectiveTest | 1540 @reflectiveTest |
1541 class ComputeInferableStaticVariableDependenciesTaskTest | |
1542 extends _AbstractDartTaskTest { | |
1543 test_perform() { | |
1544 AnalysisTarget source = newSource( | |
1545 '/test.dart', | |
1546 ''' | |
1547 const a = b; | |
1548 const b = 0; | |
1549 '''); | |
1550 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | |
1551 computeResult(target, RESOLVED_UNIT5); | |
1552 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | |
1553 TopLevelVariableElement elementA = unit.element.topLevelVariables[0]; | |
1554 TopLevelVariableElement elementB = unit.element.topLevelVariables[1]; | |
1555 | |
1556 computeResult(elementA, INFERABLE_STATIC_VARIABLE_DEPENDENCIES); | |
1557 expect(task, | |
1558 new isInstanceOf<ComputeInferableStaticVariableDependenciesTask>()); | |
1559 expect(outputs, hasLength(1)); | |
1560 Set<VariableElement> dependencies = | |
1561 outputs[INFERABLE_STATIC_VARIABLE_DEPENDENCIES]; | |
1562 expect(dependencies, unorderedEquals([elementB])); | |
1563 } | |
1564 } | |
1565 | |
1566 @reflectiveTest | |
1559 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { | 1567 class ContainingLibrariesTaskTest extends _AbstractDartTaskTest { |
1560 test_buildInputs() { | 1568 test_buildInputs() { |
1561 Map<String, TaskInput> inputs = | 1569 Map<String, TaskInput> inputs = |
1562 ContainingLibrariesTask.buildInputs(emptySource); | 1570 ContainingLibrariesTask.buildInputs(emptySource); |
1563 expect(inputs, isNotNull); | 1571 expect(inputs, isNotNull); |
1564 expect(inputs, isEmpty); | 1572 expect(inputs, isEmpty); |
1565 } | 1573 } |
1566 | 1574 |
1567 test_constructor() { | 1575 test_constructor() { |
1568 ContainingLibrariesTask task = | 1576 ContainingLibrariesTask task = |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2329 expect(sources, hasLength(lenght)); | 2337 expect(sources, hasLength(lenght)); |
2330 expect(sources, contains(predicate((Source s) { | 2338 expect(sources, contains(predicate((Source s) { |
2331 return s.fullName.endsWith('core.dart'); | 2339 return s.fullName.endsWith('core.dart'); |
2332 }))); | 2340 }))); |
2333 } | 2341 } |
2334 } | 2342 } |
2335 | 2343 |
2336 @reflectiveTest | 2344 @reflectiveTest |
2337 class PartiallyResolveReferencesTaskTest extends _AbstractDartTaskTest { | 2345 class PartiallyResolveReferencesTaskTest extends _AbstractDartTaskTest { |
2338 test_perform() { | 2346 test_perform() { |
2347 enableStrongMode(); | |
2339 Source source = newSource( | 2348 Source source = newSource( |
2340 '/test.dart', | 2349 '/test.dart', |
2341 ''' | 2350 ''' |
2342 int a = b; | 2351 int a = b; |
2343 int b = c; | 2352 int b = c; |
2353 var d = 0; | |
2354 class A {} | |
2355 class C { | |
2356 static final f = ''; | |
2357 var g = 0; | |
2358 } | |
2344 '''); | 2359 '''); |
2345 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); | 2360 LibrarySpecificUnit target = new LibrarySpecificUnit(source, source); |
2346 computeResult(target, RESOLVED_UNIT5); | 2361 computeResult(target, RESOLVED_UNIT5); |
2347 expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); | 2362 expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
2348 // Test the outputs | 2363 // Test the outputs |
2364 expect(outputs[CLASSES_IN_UNIT], hasLength(2)); | |
2365 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(2)); | |
2349 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | 2366 CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
2350 expect(unit, same(outputs[RESOLVED_UNIT5])); | 2367 expect(unit, same(outputs[RESOLVED_UNIT5])); |
2351 // Test the state of the AST | 2368 // Test the state of the AST |
2352 TopLevelVariableDeclaration a = unit.declarations[0]; | 2369 TopLevelVariableDeclaration a = unit.declarations[0]; |
2353 VariableDeclaration variableA = a.variables.variables[0]; | 2370 VariableDeclaration variableA = a.variables.variables[0]; |
2354 SimpleIdentifier initializer = variableA.initializer; | 2371 SimpleIdentifier initializer = variableA.initializer; |
2355 expect(initializer.staticElement, isNotNull); | 2372 expect(initializer.staticElement, isNotNull); |
2356 // Test the error generation | 2373 // Test the error generation |
2357 _fillErrorListener(PARTIALLY_RESOLVE_REFERENCES_ERRORS); | 2374 _fillErrorListener(PARTIALLY_RESOLVE_REFERENCES_ERRORS); |
2358 errorListener.assertErrorsWithCodes( | 2375 errorListener.assertErrorsWithCodes( |
(...skipping 20 matching lines...) Expand all Loading... | |
2379 ''' | 2396 ''' |
2380 library c; | 2397 library c; |
2381 import 'b.dart'; | 2398 import 'b.dart'; |
2382 main() { | 2399 main() { |
2383 new A<int>().m(); | 2400 new A<int>().m(); |
2384 } | 2401 } |
2385 '''); | 2402 '''); |
2386 computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT5); | 2403 computeResult(new LibrarySpecificUnit(sourceC, sourceC), RESOLVED_UNIT5); |
2387 expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); | 2404 expect(task, new isInstanceOf<PartiallyResolveUnitReferencesTask>()); |
2388 // validate | 2405 // validate |
2406 expect(outputs[CLASSES_IN_UNIT], hasLength(0)); | |
2407 expect(outputs[INFERABLE_STATIC_VARIABLES_IN_UNIT], hasLength(0)); | |
2389 CompilationUnit unit = outputs[RESOLVED_UNIT5]; | 2408 CompilationUnit unit = outputs[RESOLVED_UNIT5]; |
2390 expect(unit, isNotNull); | 2409 expect(unit, isNotNull); |
2391 | 2410 |
2392 FunctionDeclaration functionDeclaration = unit.declarations[0]; | 2411 FunctionDeclaration functionDeclaration = unit.declarations[0]; |
2393 BlockFunctionBody body = functionDeclaration.functionExpression.body; | 2412 BlockFunctionBody body = functionDeclaration.functionExpression.body; |
2394 List<Statement> statements = body.block.statements; | 2413 List<Statement> statements = body.block.statements; |
2395 ExpressionStatement statement = statements[0]; | 2414 ExpressionStatement statement = statements[0]; |
2396 MethodInvocation invocation = statement.expression; | 2415 MethodInvocation invocation = statement.expression; |
2397 MethodElement methodElement = invocation.methodName.staticElement; | 2416 MethodElement methodElement = invocation.methodName.staticElement; |
2398 expect(methodElement, isNotNull); | 2417 expect(methodElement, isNotNull); |
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2894 <script type='application/dart'>$scriptContent</script> | 2913 <script type='application/dart'>$scriptContent</script> |
2895 </head> | 2914 </head> |
2896 <body>Test</body> | 2915 <body>Test</body> |
2897 </html> | 2916 </html> |
2898 '''; | 2917 '''; |
2899 Source source = newSource('/test.html', htmlContent); | 2918 Source source = newSource('/test.html', htmlContent); |
2900 return new DartScript( | 2919 return new DartScript( |
2901 source, [new ScriptFragment(97, 5, 36, scriptContent)]); | 2920 source, [new ScriptFragment(97, 5, 36, scriptContent)]); |
2902 } | 2921 } |
2903 | 2922 |
2923 /** | |
2924 * Enable strong mode in the current analysis context. | |
2925 */ | |
2926 void enableStrongMode() { | |
2927 AnalysisOptionsImpl options = context.analysisOptions; | |
2928 options.strongMode = true; | |
2929 context.analysisOptions = options; | |
2930 } | |
2931 | |
2904 void setUp() { | 2932 void setUp() { |
2905 super.setUp(); | 2933 super.setUp(); |
2906 emptySource = newSource('/test.dart'); | 2934 emptySource = newSource('/test.dart'); |
2907 } | 2935 } |
2908 | 2936 |
2909 /** | 2937 /** |
2910 * Fill [errorListener] with [result] errors in the current [task]. | 2938 * Fill [errorListener] with [result] errors in the current [task]. |
2911 */ | 2939 */ |
2912 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { | 2940 void _fillErrorListener(ResultDescriptor<List<AnalysisError>> result) { |
2913 List<AnalysisError> errors = task.outputs[result]; | 2941 List<AnalysisError> errors = task.outputs[result]; |
2914 expect(errors, isNotNull, reason: result.name); | 2942 expect(errors, isNotNull, reason: result.name); |
2915 errorListener = new GatheringErrorListener(); | 2943 errorListener = new GatheringErrorListener(); |
2916 errorListener.addAll(errors); | 2944 errorListener.addAll(errors); |
2917 } | 2945 } |
2918 } | 2946 } |
OLD | NEW |