| 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 import 'package:analyzer/src/generated/java_core.dart'; | 8 import 'package:analyzer/src/generated/java_core.dart'; |
| 9 import 'package:analyzer/src/generated/java_engine.dart'; | 9 import 'package:analyzer/src/generated/java_engine.dart'; |
| 10 import 'package:analyzer/src/generated/java_engine_io.dart'; | 10 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 11 import 'package:analyzer/src/generated/source_io.dart'; | 11 import 'package:analyzer/src/generated/source_io.dart'; |
| 12 import 'package:analyzer/src/generated/error.dart'; | 12 import 'package:analyzer/src/generated/error.dart'; |
| 13 import 'package:analyzer/src/generated/scanner.dart'; | 13 import 'package:analyzer/src/generated/scanner.dart'; |
| 14 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 15 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; | 15 import 'package:analyzer/src/generated/parser.dart' show ParserErrorCode; |
| 16 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
| 17 import 'package:analyzer/src/generated/resolver.dart'; | 17 import 'package:analyzer/src/generated/resolver.dart'; |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/utilities_dart.dart'; | 19 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 20 import 'package:analyzer/src/generated/sdk.dart'; | 20 import 'package:analyzer/src/generated/sdk.dart'; |
| 21 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; | 21 import 'package:analyzer/src/generated/sdk_io.dart' show DirectoryBasedDartSdk; |
| 22 import 'package:unittest/unittest.dart'; | 22 import 'package:unittest/unittest.dart'; |
| 23 import 'test_support.dart'; | 23 import 'test_support.dart'; |
| 24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 24 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 25 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 25 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 26 import 'package:analyzer/src/generated/java_io.dart'; | 26 import 'package:analyzer/src/generated/java_io.dart'; |
| 27 import '../reflective_tests.dart'; | 27 import '../reflective_tests.dart'; |
| 28 import 'parser_test.dart'; |
| 28 | 29 |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts | 32 * The class `AnalysisContextFactory` defines utility methods used to create ana
lysis contexts |
| 32 * for testing purposes. | 33 * for testing purposes. |
| 33 */ | 34 */ |
| 34 class AnalysisContextFactory { | 35 class AnalysisContextFactory { |
| 35 static String _DART_MATH = "dart:math"; | 36 static String _DART_MATH = "dart:math"; |
| 36 | 37 |
| 37 static String _DART_INTERCEPTORS = "dart:_interceptors"; | 38 static String _DART_INTERCEPTORS = "dart:_interceptors"; |
| (...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 970 void test_compilationUnitMatches_false_topLevelVariable() { | 971 void test_compilationUnitMatches_false_topLevelVariable() { |
| 971 _assertCompilationUnitMatches(false, r''' | 972 _assertCompilationUnitMatches(false, r''' |
| 972 class C { | 973 class C { |
| 973 int m(int p) { | 974 int m(int p) { |
| 974 return p + p; | 975 return p + p; |
| 975 } | 976 } |
| 976 }''', r''' | 977 }''', r''' |
| 977 const int ZERO = 0; | 978 const int ZERO = 0; |
| 978 class C { | 979 class C { |
| 979 int m(int p) { | 980 int m(int p) { |
| 980 return (p * p) + (p * p) + ZERO; | 981 return p + p; |
| 981 } | 982 } |
| 982 }'''); | 983 }'''); |
| 983 } | 984 } |
| 984 | 985 |
| 985 void test_compilationUnitMatches_true_different() { | 986 void test_compilationUnitMatches_true_different() { |
| 986 _assertCompilationUnitMatches(true, r''' | 987 _assertCompilationUnitMatches(true, r''' |
| 987 class C { | 988 class C { |
| 988 int m(int p) { | 989 int m(int p) { |
| 989 return p + p; | 990 return p + p; |
| 990 } | 991 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 return p + p; | 1057 return p + p; |
| 1057 } | 1058 } |
| 1058 }'''; | 1059 }'''; |
| 1059 _assertMethodMatches(true, content, content); | 1060 _assertMethodMatches(true, content, content); |
| 1060 } | 1061 } |
| 1061 | 1062 |
| 1062 void _assertCompilationUnitMatches(bool expectMatch, String oldContent, String
newContent) { | 1063 void _assertCompilationUnitMatches(bool expectMatch, String oldContent, String
newContent) { |
| 1063 Source source = addSource(oldContent); | 1064 Source source = addSource(oldContent); |
| 1064 LibraryElement library = resolve(source); | 1065 LibraryElement library = resolve(source); |
| 1065 CompilationUnit oldUnit = resolveCompilationUnit(source, library); | 1066 CompilationUnit oldUnit = resolveCompilationUnit(source, library); |
| 1066 AnalysisContext context = analysisContext; | 1067 CompilationUnit newUnit = ParserTestCase.parseCompilationUnit(newContent, []
); |
| 1067 context.setContents(source, newContent); | |
| 1068 CompilationUnit newUnit = context.parseCompilationUnit(source); | |
| 1069 DeclarationMatcher matcher = new DeclarationMatcher(); | 1068 DeclarationMatcher matcher = new DeclarationMatcher(); |
| 1070 expect(matcher.matches(newUnit, oldUnit.element), expectMatch); | 1069 expect(matcher.matches(newUnit, oldUnit.element), expectMatch); |
| 1071 } | 1070 } |
| 1072 | 1071 |
| 1073 void _assertMethodMatches(bool expectMatch, String oldContent, String newConte
nt) { | 1072 void _assertMethodMatches(bool expectMatch, String oldContent, String newConte
nt) { |
| 1074 Source source = addSource(oldContent); | 1073 Source source = addSource(oldContent); |
| 1075 LibraryElement library = resolve(source); | 1074 LibraryElement library = resolve(source); |
| 1076 CompilationUnit oldUnit = resolveCompilationUnit(source, library); | 1075 CompilationUnit oldUnit = resolveCompilationUnit(source, library); |
| 1077 MethodElement element = _getFirstMethod(oldUnit).element as MethodElement; | 1076 MethodElement element = _getFirstMethod(oldUnit).element as MethodElement; |
| 1078 AnalysisContext context = analysisContext; | 1077 AnalysisContext context = analysisContext; |
| (...skipping 10411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11490 runReflectiveTests(TypeResolverVisitorTest); | 11489 runReflectiveTests(TypeResolverVisitorTest); |
| 11491 runReflectiveTests(CheckedModeCompileTimeErrorCodeTest); | 11490 runReflectiveTests(CheckedModeCompileTimeErrorCodeTest); |
| 11492 runReflectiveTests(ErrorResolverTest); | 11491 runReflectiveTests(ErrorResolverTest); |
| 11493 runReflectiveTests(HintCodeTest); | 11492 runReflectiveTests(HintCodeTest); |
| 11494 runReflectiveTests(MemberMapTest); | 11493 runReflectiveTests(MemberMapTest); |
| 11495 runReflectiveTests(NonHintCodeTest); | 11494 runReflectiveTests(NonHintCodeTest); |
| 11496 runReflectiveTests(SimpleResolverTest); | 11495 runReflectiveTests(SimpleResolverTest); |
| 11497 runReflectiveTests(StrictModeTest); | 11496 runReflectiveTests(StrictModeTest); |
| 11498 runReflectiveTests(TypePropagationTest); | 11497 runReflectiveTests(TypePropagationTest); |
| 11499 } | 11498 } |
| OLD | NEW |