Chromium Code Reviews| Index: pkg/analyzer/test/generated/resolver_test.dart |
| diff --git a/pkg/analyzer/test/generated/resolver_test.dart b/pkg/analyzer/test/generated/resolver_test.dart |
| index 339d4d11c97fb493012c5e42e30b465aa1325880..0b4ed05103f59310c1fd6067303cbaaa80c33a3c 100644 |
| --- a/pkg/analyzer/test/generated/resolver_test.dart |
| +++ b/pkg/analyzer/test/generated/resolver_test.dart |
| @@ -33,6 +33,7 @@ import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| import 'package:analyzer/src/generated/testing/test_type_provider.dart'; |
| import 'package:analyzer/src/generated/testing/token_factory.dart'; |
| import 'package:analyzer/src/generated/utilities_dart.dart'; |
| +import 'package:analyzer/src/string_source.dart'; |
| import 'package:unittest/unittest.dart'; |
| import '../reflective_tests.dart'; |
| @@ -100,6 +101,12 @@ class AnalysisContextFactory { |
| return initContextWithCore(context); |
| } |
| + static InternalAnalysisContext contextWithCoreAndPackages( |
| + Map<String, String> packages) { |
| + AnalysisContextForTests context = new AnalysisContextForTests(); |
| + return initContextWithCore(context, new TestPackageUriResolver(packages)); |
| + } |
| + |
| /** |
| * Initialize the given analysis context with a fake core library already resolved. |
| * |
| @@ -107,12 +114,19 @@ class AnalysisContextFactory { |
| * @return the analysis context that was created |
| */ |
| static InternalAnalysisContext initContextWithCore( |
| - InternalAnalysisContext context) { |
| + InternalAnalysisContext context, |
| + [UriResolver contributedResolver]) { |
| DirectoryBasedDartSdk sdk = new _AnalysisContextFactory_initContextWithCore( |
| new JavaFile("/fake/sdk"), |
| enableAsync: context.analysisOptions.enableAsync); |
| - SourceFactory sourceFactory = |
| - new SourceFactory([new DartUriResolver(sdk), new FileUriResolver()]); |
| + List<UriResolver> resolvers = <UriResolver>[ |
| + new DartUriResolver(sdk), |
| + new FileUriResolver() |
| + ]; |
| + if (contributedResolver != null) { |
| + resolvers.add(contributedResolver); |
| + } |
| + SourceFactory sourceFactory = new SourceFactory(resolvers); |
| context.sourceFactory = sourceFactory; |
| AnalysisContext coreContext = sdk.context; |
| (coreContext.analysisOptions as AnalysisOptionsImpl).strongMode = |
| @@ -2467,6 +2481,21 @@ class B {}'''); |
| verify([source, source2, source3]); |
| } |
| + @override |
| + void reset() { |
| + analysisContext2 = AnalysisContextFactory.contextWithCoreAndPackages({ |
| + 'package:meta/meta.dart': r''' |
| +library meta; |
| + |
| +const _Protected protected = const _Protected(); |
| + |
| +class _Protected { |
| + const _Protected(); |
| +} |
| +''' |
| + }); |
| + } |
| + |
| void test_argumentTypeNotAssignable_functionType() { |
| Source source = addSource(r''' |
| m() { |
| @@ -3549,6 +3578,51 @@ class B extends A { |
| verify([source]); |
| } |
| + void test_protected_method_call_1() { |
| + Source source = addSource(r''' |
| +import 'package:meta/meta.dart'; |
| +class A { |
| + @protected |
| + void a(){ } |
| +} |
| +main() { |
| + new A().a(); |
| +}'''); |
| + computeLibrarySourceErrors(source); |
| + assertErrors(source, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); |
| + verify([source]); |
| + } |
| + |
| + void test_protected_method_call_2() { |
| + Source source = addSource(r''' |
| +import 'package:meta/meta.dart'; |
| +class A { |
| + @protected |
| + void a(){ } |
| +} |
| +class B { |
| + void b() => new A().a(); |
| +}'''); |
| + computeLibrarySourceErrors(source); |
| + assertErrors(source, [HintCode.INVALID_USE_OF_PROTECTED_MEMBER]); |
| + verify([source]); |
| + } |
| + |
| + void test_protected_method_call_OK() { |
| + Source source = addSource(r''' |
| +import 'package:meta/meta.dart'; |
| +class A { |
| + @protected |
| + void a(){ } |
| +} |
| +class B extends A { |
|
Brian Wilkerson
2016/02/23 17:45:56
We should test "with" and "implements" relationshi
pquitslund
2016/02/23 22:59:07
Done.
|
| + void b() => a(); |
| +}'''); |
| + computeLibrarySourceErrors(source); |
| + assertErrors(source, []); |
| + verify([source]); |
| + } |
| + |
| void test_typeCheck_type_is_Null() { |
| Source source = addSource(r''' |
| m(i) { |
| @@ -14410,6 +14484,23 @@ class SubtypeManagerTest { |
| } |
| } |
| +class TestPackageUriResolver extends UriResolver { |
| + Map<Uri, Source> sourceMap = new HashMap<Uri, Source>(); |
| + |
| + TestPackageUriResolver(Map<String, String> map) { |
| + map.forEach((String uri, String contents) { |
| + sourceMap[Uri.parse(uri)] = |
| + new StringSource(contents, '/test_pkg_source.dart'); |
| + }); |
| + } |
| + |
| + @override |
| + Source resolveAbsolute(Uri uri, [Uri actualUri]) => sourceMap[uri]; |
| + |
| + @override |
| + Uri restoreAbsolute(Source source) => throw new UnimplementedError(); |
| +} |
| + |
| @reflectiveTest |
| class TypeOverrideManagerTest extends EngineTestCase { |
| void test_exitScope_noScopes() { |