| 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 engine.resolver_test; | 5 library engine.resolver_test; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/ast.dart'; | 9 import 'package:analyzer/src/generated/ast.dart'; |
| 10 import 'package:analyzer/src/generated/element.dart'; | 10 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 * Instances of the class `AnalysisContextForTests` implement an analysis contex
t that has a | 371 * Instances of the class `AnalysisContextForTests` implement an analysis contex
t that has a |
| 372 * fake SDK that is much smaller and faster for testing purposes. | 372 * fake SDK that is much smaller and faster for testing purposes. |
| 373 */ | 373 */ |
| 374 class AnalysisContextForTests extends AnalysisContextImpl { | 374 class AnalysisContextForTests extends AnalysisContextImpl { |
| 375 @override | 375 @override |
| 376 void set analysisOptions(AnalysisOptions options) { | 376 void set analysisOptions(AnalysisOptions options) { |
| 377 AnalysisOptions currentOptions = analysisOptions; | 377 AnalysisOptions currentOptions = analysisOptions; |
| 378 bool needsRecompute = | 378 bool needsRecompute = |
| 379 currentOptions.analyzeFunctionBodies != options.analyzeFunctionBodies || | 379 currentOptions.analyzeFunctionBodies != options.analyzeFunctionBodies || |
| 380 currentOptions.generateSdkErrors != options.generateSdkErrors || | 380 currentOptions.generateSdkErrors != options.generateSdkErrors || |
| 381 currentOptions.enableAsync != options.enableAsync || | |
| 382 currentOptions.enableDeferredLoading != options.enableDeferredLoading || | 381 currentOptions.enableDeferredLoading != options.enableDeferredLoading || |
| 383 currentOptions.enableEnum != options.enableEnum || | 382 currentOptions.enableEnum != options.enableEnum || |
| 384 currentOptions.dart2jsHint != options.dart2jsHint || | 383 currentOptions.dart2jsHint != options.dart2jsHint || |
| 385 (currentOptions.hint && !options.hint) || | 384 (currentOptions.hint && !options.hint) || |
| 386 currentOptions.preserveComments != options.preserveComments; | 385 currentOptions.preserveComments != options.preserveComments; |
| 387 if (needsRecompute) { | 386 if (needsRecompute) { |
| 388 fail( | 387 fail( |
| 389 "Cannot set options that cause the sources to be reanalyzed in a test
context"); | 388 "Cannot set options that cause the sources to be reanalyzed in a test
context"); |
| 390 } | 389 } |
| 391 super.analysisOptions = options; | 390 super.analysisOptions = options; |
| (...skipping 7431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7823 */ | 7822 */ |
| 7824 void reset() { | 7823 void reset() { |
| 7825 analysisContext2 = AnalysisContextFactory.contextWithCore(); | 7824 analysisContext2 = AnalysisContextFactory.contextWithCore(); |
| 7826 // These defaults are duplicated for the editor in | 7825 // These defaults are duplicated for the editor in |
| 7827 // editor/tools/plugins/com.google.dart.tools.core/.options . | 7826 // editor/tools/plugins/com.google.dart.tools.core/.options . |
| 7828 AnalysisEngine.instance.enableUnionTypes = false; | 7827 AnalysisEngine.instance.enableUnionTypes = false; |
| 7829 AnalysisEngine.instance.strictUnionTypes = false; | 7828 AnalysisEngine.instance.strictUnionTypes = false; |
| 7830 } | 7829 } |
| 7831 | 7830 |
| 7832 /** | 7831 /** |
| 7833 * Reset the analysis context to have the 'enableAsync' option set to true. | |
| 7834 */ | |
| 7835 void resetWithAsync() { | |
| 7836 AnalysisOptionsImpl options = new AnalysisOptionsImpl(); | |
| 7837 options.enableAsync = true; | |
| 7838 analysisContext2 = | |
| 7839 AnalysisContextFactory.contextWithCoreAndOptions(options); | |
| 7840 } | |
| 7841 | |
| 7842 /** | |
| 7843 * Reset the analysis context to have the 'enableEnum' option set to true. | 7832 * Reset the analysis context to have the 'enableEnum' option set to true. |
| 7844 */ | 7833 */ |
| 7845 void resetWithEnum() { | 7834 void resetWithEnum() { |
| 7846 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); | 7835 AnalysisOptionsImpl analysisOptions = new AnalysisOptionsImpl(); |
| 7847 analysisOptions.enableEnum = true; | 7836 analysisOptions.enableEnum = true; |
| 7848 resetWithOptions(analysisOptions); | 7837 resetWithOptions(analysisOptions); |
| 7849 } | 7838 } |
| 7850 | 7839 |
| 7851 /** | 7840 /** |
| 7852 * Reset the analysis context to have the given options applied. | 7841 * Reset the analysis context to have the given options applied. |
| (...skipping 5976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13829 // check propagated type | 13818 // check propagated type |
| 13830 FunctionType propagatedType = node.propagatedType as FunctionType; | 13819 FunctionType propagatedType = node.propagatedType as FunctionType; |
| 13831 expect(propagatedType.returnType, test.typeProvider.stringType); | 13820 expect(propagatedType.returnType, test.typeProvider.stringType); |
| 13832 } on AnalysisException catch (e, stackTrace) { | 13821 } on AnalysisException catch (e, stackTrace) { |
| 13833 thrownException[0] = new CaughtException(e, stackTrace); | 13822 thrownException[0] = new CaughtException(e, stackTrace); |
| 13834 } | 13823 } |
| 13835 } | 13824 } |
| 13836 return null; | 13825 return null; |
| 13837 } | 13826 } |
| 13838 } | 13827 } |
| OLD | NEW |