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

Unified Diff: pkg/analysis_server/test/completion_test_support.dart

Issue 798173004: Add filtering to completion tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/completion_test_support.dart
diff --git a/pkg/analysis_server/test/completion_test_support.dart b/pkg/analysis_server/test/completion_test_support.dart
index bca1b38b44361644c1212c0164950b2c567fb31d..3d4157a040f820f88a518f3bb32ea627664e1c5c 100644
--- a/pkg/analysis_server/test/completion_test_support.dart
+++ b/pkg/analysis_server/test/completion_test_support.dart
@@ -4,6 +4,7 @@
library test.completion.support;
+import 'dart:async';
import 'dart:collection';
import 'package:analysis_server/src/protocol.dart';
@@ -11,7 +12,6 @@ import 'package:analyzer/src/generated/java_core.dart';
import 'package:unittest/unittest.dart';
import 'domain_completion_test.dart';
-import 'dart:async';
/**
* A base class for classes containing completion tests.
@@ -53,9 +53,6 @@ class CompletionTestCase extends CompletionTest {
}
void assertHasNoCompletion(String completion) {
- // As a temporary measure, disable negative tests.
- // TODO(paulberry): fix this.
- return;
if (suggestions.any(
(CompletionSuggestion suggestion) => suggestion.completion == completion)) {
fail(
@@ -63,6 +60,18 @@ class CompletionTestCase extends CompletionTest {
}
}
+ /**
+ * Discard any results that do not start with the characters the user has
+ * "already typed".
+ */
+ void filterResults(String content) {
+ String charsAlreadyTyped =
+ content.substring(replacementOffset, completionOffset).toLowerCase();
+ suggestions = suggestions.where(
+ (CompletionSuggestion suggestion) =>
+ suggestion.completion.toLowerCase().startsWith(charsAlreadyTyped)).toList();
+ }
+
runTest(LocationSpec spec, [Map<String, String> extraFiles]) {
super.setUp();
return new Future(() {
@@ -76,8 +85,7 @@ class CompletionTestCase extends CompletionTest {
});
}
}).then((_) => getSuggestions()).then((_) {
- //expect(replacementOffset, equals(completionOffset));
- //expect(replacementLength, equals(0));
+ filterResults(spec.source);
for (String result in spec.positiveResults) {
assertHasCompletion(result);
}
« no previous file with comments | « pkg/analysis_server/test/completion_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698