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

Unified Diff: pkg/analyzer/test/src/summary/name_filter_test.dart

Issue 1574053002: Move NameFilter to its own file so it can be conveniently reused. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 11 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
Index: pkg/analyzer/test/src/summary/name_filter_test.dart
diff --git a/pkg/analyzer/test/src/summary/prelink_test.dart b/pkg/analyzer/test/src/summary/name_filter_test.dart
similarity index 66%
rename from pkg/analyzer/test/src/summary/prelink_test.dart
rename to pkg/analyzer/test/src/summary/name_filter_test.dart
index b3a1ba0955d38934f47c58f754a5a4ccfde5765f..a3c9ae57f53b852f56c1ff2c732df3e879e3dd35 100644
--- a/pkg/analyzer/test/src/summary/prelink_test.dart
+++ b/pkg/analyzer/test/src/summary/name_filter_test.dart
@@ -2,8 +2,9 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+import 'package:analyzer/src/dart/element/element.dart';
import 'package:analyzer/src/summary/format.dart';
-import 'package:analyzer/src/summary/prelink.dart';
+import 'package:analyzer/src/summary/name_filter.dart';
import 'package:unittest/unittest.dart';
import '../../reflective_tests.dart';
@@ -33,7 +34,7 @@ class MockUnlinkedCombinator implements UnlinkedCombinator {
@reflectiveTest
class NameFilterTest {
test_accepts_accessors_hide() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(hides: ['bar']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('foo='), isTrue);
@@ -42,7 +43,7 @@ class NameFilterTest {
}
test_accepts_accessors_show() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('foo='), isTrue);
@@ -50,8 +51,43 @@ class NameFilterTest {
expect(filter.accepts('bar='), isFalse);
}
- test_forCombinator_hide() {
- NameFilter filter = new NameFilter.forCombinator(
+ test_forNamespaceCombinator_hide() {
+ NameFilter filter = new NameFilter.forNamespaceCombinator(
+ new HideElementCombinatorImpl()..hiddenNames = ['foo', 'bar']);
+ expect(filter.accepts('foo'), isFalse);
+ expect(filter.accepts('bar'), isFalse);
+ expect(filter.accepts('baz'), isTrue);
+ expect(filter.shownNames, isNull);
+ expect(filter.hiddenNames, isNotNull);
+ expect(filter.hiddenNames, ['foo', 'bar'].toSet());
+ }
+
+ test_forNamespaceCombinator_show() {
+ NameFilter filter = new NameFilter.forNamespaceCombinator(
+ new ShowElementCombinatorImpl()..shownNames = ['foo', 'bar']);
+ expect(filter.accepts('foo'), isTrue);
+ expect(filter.accepts('bar'), isTrue);
+ expect(filter.accepts('baz'), isFalse);
+ expect(filter.hiddenNames, isNull);
+ expect(filter.shownNames, isNotNull);
+ expect(filter.shownNames, ['foo', 'bar'].toSet());
+ }
+
+ test_forNamespaceCombinators() {
+ NameFilter filter = new NameFilter.forNamespaceCombinators([
+ new HideElementCombinatorImpl()..hiddenNames = ['foo'],
+ new HideElementCombinatorImpl()..hiddenNames = ['bar']
+ ]);
+ expect(filter.accepts('foo'), isFalse);
+ expect(filter.accepts('bar'), isFalse);
+ expect(filter.accepts('baz'), isTrue);
+ expect(filter.shownNames, isNull);
+ expect(filter.hiddenNames, isNotNull);
+ expect(filter.hiddenNames, ['foo', 'bar'].toSet());
+ }
+
+ test_forUnlinkedCombinator_hide() {
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(hides: ['foo', 'bar']));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
@@ -61,8 +97,8 @@ class NameFilterTest {
expect(filter.hiddenNames, ['foo', 'bar'].toSet());
}
- test_forCombinator_show() {
- NameFilter filter = new NameFilter.forCombinator(
+ test_forUnlinkedCombinator_show() {
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo', 'bar']));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isTrue);
@@ -72,8 +108,8 @@ class NameFilterTest {
expect(filter.shownNames, ['foo', 'bar'].toSet());
}
- test_forCombinators() {
- NameFilter filter = new NameFilter.forCombinators([
+ test_forUnlinkedCombinators() {
+ NameFilter filter = new NameFilter.forUnlinkedCombinators([
new MockUnlinkedCombinator(hides: ['foo']),
new MockUnlinkedCombinator(hides: ['bar'])
]);
@@ -93,10 +129,10 @@ class NameFilterTest {
}
test_merge_hides_hides() {
- NameFilter filter =
- new NameFilter.forCombinator(new MockUnlinkedCombinator(hides: ['foo']))
- .merge(new NameFilter.forCombinator(
- new MockUnlinkedCombinator(hides: ['bar'])));
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(hides: ['foo'])).merge(
+ new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(hides: ['bar'])));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isTrue);
@@ -106,7 +142,7 @@ class NameFilterTest {
}
test_merge_hides_identity() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(hides: ['foo', 'bar']))
.merge(NameFilter.identity);
expect(filter.accepts('foo'), isFalse);
@@ -118,9 +154,9 @@ class NameFilterTest {
}
test_merge_hides_shows() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(hides: ['bar', 'baz'])).merge(
- new NameFilter.forCombinator(
+ new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo', 'bar'])));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isFalse);
@@ -131,8 +167,9 @@ class NameFilterTest {
}
test_merge_identity_hides() {
- NameFilter filter = NameFilter.identity.merge(new NameFilter.forCombinator(
- new MockUnlinkedCombinator(hides: ['foo', 'bar'])));
+ NameFilter filter = NameFilter.identity.merge(
+ new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(hides: ['foo', 'bar'])));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isTrue);
@@ -150,8 +187,9 @@ class NameFilterTest {
}
test_merge_identity_shows() {
- NameFilter filter = NameFilter.identity.merge(new NameFilter.forCombinator(
- new MockUnlinkedCombinator(shows: ['foo', 'bar'])));
+ NameFilter filter = NameFilter.identity.merge(
+ new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(shows: ['foo', 'bar'])));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isTrue);
expect(filter.accepts('baz'), isFalse);
@@ -161,9 +199,9 @@ class NameFilterTest {
}
test_merge_shows_hides() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo', 'bar'])).merge(
- new NameFilter.forCombinator(
+ new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(hides: ['bar', 'baz'])));
expect(filter.accepts('foo'), isTrue);
expect(filter.accepts('bar'), isFalse);
@@ -174,7 +212,7 @@ class NameFilterTest {
}
test_merge_shows_identity() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo', 'bar']))
.merge(NameFilter.identity);
expect(filter.accepts('foo'), isTrue);
@@ -186,9 +224,9 @@ class NameFilterTest {
}
test_merge_shows_shows() {
- NameFilter filter = new NameFilter.forCombinator(
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['foo', 'bar'])).merge(
- new NameFilter.forCombinator(
+ new NameFilter.forUnlinkedCombinator(
new MockUnlinkedCombinator(shows: ['bar', 'baz'])));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isTrue);
@@ -199,10 +237,10 @@ class NameFilterTest {
}
test_merge_shows_shows_emptyResult() {
- NameFilter filter =
- new NameFilter.forCombinator(new MockUnlinkedCombinator(shows: ['foo']))
- .merge(new NameFilter.forCombinator(
- new MockUnlinkedCombinator(shows: ['bar'])));
+ NameFilter filter = new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(shows: ['foo'])).merge(
+ new NameFilter.forUnlinkedCombinator(
+ new MockUnlinkedCombinator(shows: ['bar'])));
expect(filter.accepts('foo'), isFalse);
expect(filter.accepts('bar'), isFalse);
expect(filter.accepts('baz'), isFalse);
« no previous file with comments | « pkg/analyzer/lib/src/summary/summarize_elements.dart ('k') | pkg/analyzer/test/src/summary/prelink_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698