Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 2047273004: Add bounds check in scope lookup (issue 26633) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/resolver/scope.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 analyzer.test.generated.resolver_test; 5 library analyzer.test.generated.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/dart/ast/ast.dart'; 9 import 'package:analyzer/dart/ast/ast.dart';
10 import 'package:analyzer/dart/ast/token.dart'; 10 import 'package:analyzer/dart/ast/token.dart';
(...skipping 24 matching lines...) Expand all
35 35
36 main() { 36 main() {
37 initializeTestEnvironment(); 37 initializeTestEnvironment();
38 runReflectiveTests(AnalysisDeltaTest); 38 runReflectiveTests(AnalysisDeltaTest);
39 runReflectiveTests(ChangeSetTest); 39 runReflectiveTests(ChangeSetTest);
40 runReflectiveTests(DisableAsyncTestCase); 40 runReflectiveTests(DisableAsyncTestCase);
41 runReflectiveTests(EnclosedScopeTest); 41 runReflectiveTests(EnclosedScopeTest);
42 runReflectiveTests(ErrorResolverTest); 42 runReflectiveTests(ErrorResolverTest);
43 runReflectiveTests(LibraryImportScopeTest); 43 runReflectiveTests(LibraryImportScopeTest);
44 runReflectiveTests(LibraryScopeTest); 44 runReflectiveTests(LibraryScopeTest);
45 runReflectiveTests(PrefixedNamespaceTest);
45 runReflectiveTests(ScopeTest); 46 runReflectiveTests(ScopeTest);
46 runReflectiveTests(StrictModeTest); 47 runReflectiveTests(StrictModeTest);
47 runReflectiveTests(SubtypeManagerTest); 48 runReflectiveTests(SubtypeManagerTest);
48 runReflectiveTests(TypeOverrideManagerTest); 49 runReflectiveTests(TypeOverrideManagerTest);
49 runReflectiveTests(TypePropagationTest); 50 runReflectiveTests(TypePropagationTest);
50 runReflectiveTests(TypeProviderImplTest); 51 runReflectiveTests(TypeProviderImplTest);
51 runReflectiveTests(TypeResolverVisitorTest); 52 runReflectiveTests(TypeResolverVisitorTest);
52 } 53 }
53 54
54 @reflectiveTest 55 @reflectiveTest
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 } 529 }
529 530
530 void test_getErrorListener() { 531 void test_getErrorListener() {
531 LibraryElement definingLibrary = createDefaultTestLibrary(); 532 LibraryElement definingLibrary = createDefaultTestLibrary();
532 GatheringErrorListener errorListener = new GatheringErrorListener(); 533 GatheringErrorListener errorListener = new GatheringErrorListener();
533 LibraryScope scope = new LibraryScope(definingLibrary, errorListener); 534 LibraryScope scope = new LibraryScope(definingLibrary, errorListener);
534 expect(scope.errorListener, errorListener); 535 expect(scope.errorListener, errorListener);
535 } 536 }
536 } 537 }
537 538
539 @reflectiveTest
540 class PrefixedNamespaceTest extends ResolverTestCase {
541 void test_lookup_missing() {
542 ClassElement element = ElementFactory.classElement2('A');
543 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
544 expect(namespace.get('p.B'), isNull);
545 }
546
547 void test_lookup_missing_matchesPrefix() {
548 ClassElement element = ElementFactory.classElement2('A');
549 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
550 expect(namespace.get('p'), isNull);
551 }
552
553 void test_lookup_valid() {
554 ClassElement element = ElementFactory.classElement2('A');
555 PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
556 expect(namespace.get('p.A'), same(element));
557 }
558
559 HashMap<String, Element> _toMap(List<Element> elements) {
560 HashMap<String, Element> map = new HashMap<String, Element>();
561 for (Element element in elements) {
562 map[element.name] = element;
563 }
564 return map;
565 }
566 }
567
538 class Scope_EnclosedScopeTest_test_define_duplicate extends Scope { 568 class Scope_EnclosedScopeTest_test_define_duplicate extends Scope {
539 GatheringErrorListener listener; 569 GatheringErrorListener listener;
540 570
541 Scope_EnclosedScopeTest_test_define_duplicate(this.listener) : super(); 571 Scope_EnclosedScopeTest_test_define_duplicate(this.listener) : super();
542 572
543 @override 573 @override
544 AnalysisErrorListener get errorListener => listener; 574 AnalysisErrorListener get errorListener => listener;
545 575
546 @override 576 @override
547 Element internalLookup(Identifier identifier, String name, 577 Element internalLookup(Identifier identifier, String name,
(...skipping 3049 matching lines...) Expand 10 before | Expand all | Expand 10 after
3597 */ 3627 */
3598 class _StaleElement extends ElementImpl { 3628 class _StaleElement extends ElementImpl {
3599 _StaleElement() : super("_StaleElement", -1); 3629 _StaleElement() : super("_StaleElement", -1);
3600 3630
3601 @override 3631 @override
3602 get kind => throw "_StaleElement's kind shouldn't be accessed"; 3632 get kind => throw "_StaleElement's kind shouldn't be accessed";
3603 3633
3604 @override 3634 @override
3605 accept(_) => throw "_StaleElement shouldn't be visited"; 3635 accept(_) => throw "_StaleElement shouldn't be visited";
3606 } 3636 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/dart/resolver/scope.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698