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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/dart/resolver/scope.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11eee0be474ebcd0234f35c4e42aff557bb072db..102956ae860a7fdacc0d565196d82cb2b2a17888 100644
--- a/pkg/analyzer/test/generated/resolver_test.dart
+++ b/pkg/analyzer/test/generated/resolver_test.dart
@@ -42,6 +42,7 @@ main() {
runReflectiveTests(ErrorResolverTest);
runReflectiveTests(LibraryImportScopeTest);
runReflectiveTests(LibraryScopeTest);
+ runReflectiveTests(PrefixedNamespaceTest);
runReflectiveTests(ScopeTest);
runReflectiveTests(StrictModeTest);
runReflectiveTests(SubtypeManagerTest);
@@ -535,6 +536,35 @@ class LibraryScopeTest extends ResolverTestCase {
}
}
+@reflectiveTest
+class PrefixedNamespaceTest extends ResolverTestCase {
+ void test_lookup_missing() {
+ ClassElement element = ElementFactory.classElement2('A');
+ PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ expect(namespace.get('p.B'), isNull);
+ }
+
+ void test_lookup_missing_matchesPrefix() {
+ ClassElement element = ElementFactory.classElement2('A');
+ PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ expect(namespace.get('p'), isNull);
+ }
+
+ void test_lookup_valid() {
+ ClassElement element = ElementFactory.classElement2('A');
+ PrefixedNamespace namespace = new PrefixedNamespace('p', _toMap([element]));
+ expect(namespace.get('p.A'), same(element));
+ }
+
+ HashMap<String, Element> _toMap(List<Element> elements) {
+ HashMap<String, Element> map = new HashMap<String, Element>();
+ for (Element element in elements) {
+ map[element.name] = element;
+ }
+ return map;
+ }
+}
+
class Scope_EnclosedScopeTest_test_define_duplicate extends Scope {
GatheringErrorListener listener;
« 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