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

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

Issue 820773002: Introduce CompletionTarget to take the place of the Node being completed. (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
Index: pkg/analysis_server/test/completion_test.dart
diff --git a/pkg/analysis_server/test/completion_test.dart b/pkg/analysis_server/test/completion_test.dart
index 969c444a36b9700cacaabca3626113ced77b1301..464765b3dad51cbf7f63e2e5554beba15c2faf92 100644
--- a/pkg/analysis_server/test/completion_test.dart
+++ b/pkg/analysis_server/test/completion_test.dart
@@ -11,12 +11,23 @@ import 'package:unittest/unittest.dart';
import 'completion_test_support.dart';
+/**
+ * Assigning the name of a single test to this string causes just that test to
+ * be run. Assigning null to this string causes all tests to be run.
+ */
+const String SOLO_TEST = null;
+
main() {
CompletionTestBuilder builder = new CompletionTestBuilder();
builder.buildAll();
}
/**
+ * Type of functions used to create tests.
+ */
+typedef void _Tester(String spec, TestFunction body);
+
+/**
* A builder that builds the completion tests.
*/
class CompletionTestBuilder {
@@ -93,7 +104,7 @@ class x implements M!1{}''', <String>["1+Map"]);
class x implements M!1\n{}''', <String>["1+Map"]);
buildTests('testCommentSnippets013', '''
-class x !2{!1}!3''', <String>["1+num", "2-num", "3-num"], failingTests: '3');
+class x !2{!1}!3''', <String>["1+num", "2-num", "3+num"]);
// trailing space is important
buildTests('testCommentSnippets014', '''
@@ -234,8 +245,7 @@ class List{}class XXX {XXX.fisk();}main() {main(); new !1}}''',
f(){int x;int y=!1;}''', <String>["1+x"]);
buildTests('testCommentSnippets048', '''
-import 'dart:convert' as json;f() {var x=new js!1}''',
- <String>["1+json"]);
+import 'dart:convert' as json;f() {var x=new js!1}''', <String>["1+json"]);
buildTests('testCommentSnippets049', '''
import 'dart:convert' as json;
@@ -834,7 +844,7 @@ class MyClass {}
main(p) {
var justSomeVar;
var v = p as !1
-}''', <String>["1+MyClass", "1-justSomeVar"], failingTests: '1');
+}''', <String>["1+MyClass", "1-justSomeVar"]);
buildTests('testCompletion_cascade', '''
class A {
@@ -988,7 +998,7 @@ class C {}''',
buildTests('testCompletion_double_inFractionPart', '''
main() {
1.0!1
-}''', <String>["1-abs", "1-main"], failingTests: '1');
+}''', <String>["1-abs", "1-main"]);
buildTests('testCompletion_enum', '''
enum MyEnum {A, B, C}
@@ -1206,7 +1216,7 @@ class MyClass {}
main(p) {
var justSomeVar;
var v = p is !1
-}''', <String>["1+MyClass", "1-justSomeVar"], failingTests: '1');
+}''', <String>["1+MyClass", "1-justSomeVar"]);
buildTests('testCompletion_is_incompleteStatement2', '''
class MyClass {}
@@ -1226,10 +1236,10 @@ main() {
}''', <String>["1+caseVar", "1-otherVar"]);
buildTests('testCompletion_libraryIdentifier_atEOF', '''
-library int.!1''', <String>["1-parse", "1-bool"], failingTests: '1');
+library int.!1''', <String>["1-parse", "1-bool"]);
buildTests('testCompletion_libraryIdentifier_notEOF', '''
-library int.!1''', <String>["1-parse", "1-bool"], failingTests: '1');
+library int.!1''', <String>["1-parse", "1-bool"]);
buildTests('testCompletion_methodRef_asArg_incompatibleFunctionType', '''
foo( f(int p) ) {}
@@ -1431,7 +1441,7 @@ f() { var vvv = 42; return !1 }''', <String>["1+vvv"]);
buildTests('testCompletion_staticField1', '''
class num{}class Sunflower {static final n!2um MAX_D = 300;nu!3m xc, yc;Sun!4flower() {x!Xc = y!Yc = MA!1 }}''',
<String>["1+MAX_D", "X+xc", "Y+yc", "2+num", "3+num", "4+Sunflower"],
- failingTests: '234');
+ failingTests: '23');
buildTests('testCompletion_super_superType', '''
class A {
@@ -1608,7 +1618,7 @@ library firth;
class SerializationException {
const SerializationException();
}''';
- buildTests('test001', '''
+ buildTests('testLibrary001', '''
import 'firth.dart';
main() {
throw new Seria!1lizationException();}''',
@@ -1619,21 +1629,21 @@ throw new Seria!1lizationException();}''',
// Type propagation.
// TODO Include corelib analysis (this works in the editor)
buildTests(
- 'test002',
+ 'testLibrary002',
'''t2() {var q=[0],z=q.!1length;q.!2clear();}''',
<String>["1+length", "1+isEmpty", "2+clear"],
failingTests: '1');
// TODO Include corelib analysis
buildTests(
- 'test003',
+ 'testLibrary003',
'''class X{var q; f() {q.!1a!2}}''',
<String>["1+end", "2+abs", "2-end"],
failingTests: '12');
// TODO Include corelib analysis
// Resolving dart:html takes between 2.5s and 30s; json, about 0.12s
- buildTests('test004', '''
+ buildTests('testLibrary004', '''
library foo;
import 'dart:convert' as json;
class JsonDecoderX{}
@@ -1651,7 +1661,7 @@ throw new Seria!1lizationException();}''',
// TODO Enable after type propagation is implemented. Not yet.
// TODO Include corelib analysis
buildTests(
- 'test005',
+ 'testLibrary005',
'''var PHI;main(){PHI=5.3;PHI.abs().!1 Object x;}''',
<String>["1+abs"],
failingTests: '1');
@@ -1677,7 +1687,7 @@ i1() {}''';
library imp2;
export 'exp2a.dart';
i2() {}''';
- buildTests('test006', '''
+ buildTests('testLibrary006', '''
import 'imp1.dart';
import 'imp2.dart';
main() {!1
@@ -1697,7 +1707,7 @@ main() {!1
sources["/l1.dart"] = '''
library l1;
var _l1t; var l1t;''';
- buildTests('test007', '''
+ buildTests('testLibrary007', '''
import 'l1.dart';
main() {
var x = l!1
@@ -1722,7 +1732,7 @@ class Private extends NonPrivate {
void privateMethod() {
}
}''';
- buildTests('test008', '''
+ buildTests('testLibrary008', '''
import 'private.dart';
import 'public.dart';
class Test {
@@ -1742,7 +1752,7 @@ library lib;
int X = 1;
void m(){}
class Y {}''';
- buildTests('test009', '''
+ buildTests('testLibrary009', '''
import 'lib.dart' as Q;
void a() {
var x = Q.!1
@@ -1901,26 +1911,26 @@ typ!7edef !5n!6''',
class test !8<!1t !2 !3extends String,!4 List,!5 !6>!7 {}
class tezetst !9<!BString,!C !DList>!A {}''',
<String>[
- "1+String",
- "1+List",
+ "1-String",
+ "1-List",
"1-test",
"2-String",
"2-test",
"3+extends",
- "4+tezetst",
+ "4-tezetst",
"4-test",
- "5+String",
- "6+List",
+ "5-String",
+ "6-List",
"7-List",
"8-List",
"9-String",
"A-String",
- "B+String",
- "C+List",
+ "B-String",
+ "C-List",
"C-tezetst",
- "D+List",
- "D+test"],
- failingTests: '12345C');
+ "D-List",
+ "D-test"],
+ failingTests: '23');
// name generation with conflicts
buildTests(
@@ -2365,9 +2375,11 @@ class A<Z extends X> {
}
}
for (LocationSpec spec in completionTests) {
+ String testName = '$baseName-${spec.id}';
+ _Tester tester = testName == SOLO_TEST ? solo_test : test;
if (failingTests.contains(spec.id)) {
++expectedFailCount;
- test("$baseName-${spec.id} (expected failure)", () {
+ tester("$testName (expected failure $expectedFailCount)", () {
CompletionTestCase test = new CompletionTestCase();
return new Future(() => test.runTest(spec, extraFiles)).then((_) {
fail('Test passed - expected to fail.');
@@ -2375,7 +2387,7 @@ class A<Z extends X> {
});
} else {
++expectedPassCount;
- test("$baseName-${spec.id}", () {
+ tester(testName, () {
CompletionTestCase test = new CompletionTestCase();
return test.runTest(spec, extraFiles);
});

Powered by Google App Engine
This is Rietveld 408576698