Chromium Code Reviews| Index: pkg/analysis_server/test/services/completion/completion_target_test.dart |
| diff --git a/pkg/analysis_server/test/services/completion/completion_target_test.dart b/pkg/analysis_server/test/services/completion/completion_target_test.dart |
| index c553188b576062e8fd69ae4d6edbc0be112b1fbe..9e97accbd958c2dd10565e7c2fd7e34ded41b84b 100644 |
| --- a/pkg/analysis_server/test/services/completion/completion_target_test.dart |
| +++ b/pkg/analysis_server/test/services/completion/completion_target_test.dart |
| @@ -4,8 +4,11 @@ |
| library test.services.completion.target; |
| +import 'dart:async'; |
| + |
| import 'package:analysis_server/src/provisional/completion/dart/completion_target.dart'; |
| import 'package:analyzer/dart/ast/ast.dart'; |
| +import 'package:analyzer/src/dart/analysis/driver.dart'; |
| import 'package:analyzer/src/generated/source.dart'; |
| import 'package:test/test.dart'; |
| import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| @@ -24,7 +27,10 @@ class CompletionTargetTest extends AbstractContextTest { |
| int completionOffset; |
| CompletionTarget target; |
| - void addTestSource(String content) { |
| + @override |
| + bool get enableNewAnalysisDriver => true; |
| + |
| + Future<Null> addTestSource(String content) async { |
| expect(completionOffset, isNull, reason: 'Call addTestSource exactly once'); |
| completionOffset = content.indexOf('^'); |
| expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); |
| @@ -33,12 +39,12 @@ class CompletionTargetTest extends AbstractContextTest { |
| content = content.substring(0, completionOffset) + |
| content.substring(completionOffset + 1); |
| testSource = addSource('/test.dart', content); |
| - CompilationUnit unit = context.parseCompilationUnit(testSource); |
| - target = new CompletionTarget.forOffset(unit, completionOffset); |
| + AnalysisResult result = await driver.getResult(testSource.fullName); |
|
scheglov
2017/05/05 19:37:12
I think that practically we don't use "testSource"
Brian Wilkerson
2017/05/05 20:19:59
There are currently over 700 invocations of addSou
|
| + target = new CompletionTarget.forOffset(result.unit, completionOffset); |
| } |
| - void assertTarget(entityText, nodeText, |
| - {int argIndex: null, bool isFunctionalArgument: false}) { |
| + Future<Null> assertTarget(entityText, nodeText, |
| + {int argIndex: null, bool isFunctionalArgument: false}) async { |
| void assertCommon() { |
| expect(target.entity.toString(), entityText, reason: 'entity'); |
| expect(target.containingNode.toString(), nodeText, |
| @@ -48,543 +54,553 @@ class CompletionTargetTest extends AbstractContextTest { |
| // Assert with parsed unit |
| assertCommon(); |
| - CompilationUnit unit = |
| - context.resolveCompilationUnit2(testSource, testSource); |
| - target = new CompletionTarget.forOffset(unit, completionOffset); |
| + AnalysisResult result = await driver.getResult(testSource.fullName); |
| + target = new CompletionTarget.forOffset(result.unit, completionOffset); |
| // Assert more with resolved unit |
| assertCommon(); |
| expect(target.isFunctionalArgument(), isFunctionalArgument); |
| } |
| - test_ArgumentList_InstanceCreationExpression() { |
| + test_ArgumentList_InstanceCreationExpression() async { |
| // ArgumentList InstanceCreationExpression Block |
| - addTestSource('main() {new Foo(^)}'); |
| - assertTarget(')', '()', argIndex: 0); |
| + await addTestSource('main() {new Foo(^)}'); |
| + await assertTarget(')', '()', argIndex: 0); |
| } |
| - test_ArgumentList_InstanceCreationExpression2() { |
| + test_ArgumentList_InstanceCreationExpression2() async { |
| // ArgumentList InstanceCreationExpression Block |
| - addTestSource('main() {new Foo(a,^)}'); |
| - assertTarget(')', '(a)', argIndex: 1); |
| + await addTestSource('main() {new Foo(a,^)}'); |
| + await assertTarget(')', '(a)', argIndex: 1); |
| } |
| - test_ArgumentList_InstanceCreationExpression_functionArg2() { |
| + test_ArgumentList_InstanceCreationExpression_functionArg2() async { |
| // ArgumentList InstanceCreationExpression Block |
| - addTestSource('main() {new B(^)} class B{B(f()){}}'); |
| - assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| + await addTestSource('main() {new B(^)} class B{B(f()){}}'); |
| + await assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| } |
| - test_ArgumentList_InstanceCreationExpression_functionArg3() { |
| + test_ArgumentList_InstanceCreationExpression_functionArg3() async { |
| // ArgumentList InstanceCreationExpression Block |
| - addTestSource('main() {new B(1, f: ^)} class B{B(int i, {f()}){}}'); |
| - assertTarget('', 'f: ', argIndex: 1, isFunctionalArgument: true); |
| + await addTestSource('main() {new B(1, f: ^)} class B{B(int i, {f()}){}}'); |
| + await assertTarget('', 'f: ', argIndex: 1, isFunctionalArgument: true); |
| } |
| - test_ArgumentList_MethodInvocation() { |
| + test_ArgumentList_MethodInvocation() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(^)}'); |
| - assertTarget(')', '()', argIndex: 0); |
| + await addTestSource('main() {foo(^)}'); |
| + await assertTarget(')', '()', argIndex: 0); |
| } |
| - test_ArgumentList_MethodInvocation2() { |
| + test_ArgumentList_MethodInvocation2() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(^n)}'); |
| - assertTarget('n', '(n)', argIndex: 0); |
| + await addTestSource('main() {foo(^n)}'); |
| + await assertTarget('n', '(n)', argIndex: 0); |
| } |
| - test_ArgumentList_MethodInvocation3() { |
| + test_ArgumentList_MethodInvocation3() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(n^)}'); |
| - assertTarget('n', '(n)', argIndex: 0); |
| + await addTestSource('main() {foo(n^)}'); |
| + await assertTarget('n', '(n)', argIndex: 0); |
| } |
| - test_ArgumentList_MethodInvocation3a() { |
| + test_ArgumentList_MethodInvocation3a() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo((n)^)}'); |
| - assertTarget(')', '((n))', argIndex: 0); |
| + await addTestSource('main() {foo((n)^)}'); |
| + await assertTarget(')', '((n))', argIndex: 0); |
| } |
| - test_ArgumentList_MethodInvocation4() { |
| + test_ArgumentList_MethodInvocation4() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(n,^)}'); |
| - assertTarget(')', '(n)', argIndex: 1); |
| + await addTestSource('main() {foo(n,^)}'); |
| + await assertTarget(')', '(n)', argIndex: 1); |
| } |
| - test_ArgumentList_MethodInvocation_functionArg() { |
| + test_ArgumentList_MethodInvocation_functionArg() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(^)} foo(f()) {}'); |
| - assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| + await addTestSource('main() {foo(^)} foo(f()) {}'); |
| + await assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| } |
| - test_ArgumentList_MethodInvocation_functionArg2() { |
| + test_ArgumentList_MethodInvocation_functionArg2() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {new B().boo(^)} class B{boo(f()){}}'); |
| - assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| + await addTestSource('main() {new B().boo(^)} class B{boo(f()){}}'); |
| + await assertTarget(')', '()', argIndex: 0, isFunctionalArgument: true); |
| } |
| - test_ArgumentList_MethodInvocation_functionArg3() { |
| + test_ArgumentList_MethodInvocation_functionArg3() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {foo(f: ^)} foo({f()}) {}'); |
| - assertTarget('', 'f: ', argIndex: 0, isFunctionalArgument: true); |
| + await addTestSource('main() {foo(f: ^)} foo({f()}) {}'); |
| + await assertTarget('', 'f: ', argIndex: 0, isFunctionalArgument: true); |
| } |
| - test_ArgumentList_MethodInvocation_functionArg4() { |
| + test_ArgumentList_MethodInvocation_functionArg4() async { |
| // ArgumentList MethodInvocation Block |
| - addTestSource('main() {new B().boo(f: ^)} class B{boo({f()}){}}'); |
| - assertTarget('', 'f: ', argIndex: 0, isFunctionalArgument: true); |
| + await addTestSource('main() {new B().boo(f: ^)} class B{boo({f()}){}}'); |
| + await assertTarget('', 'f: ', argIndex: 0, isFunctionalArgument: true); |
| } |
| - test_AsExpression_identifier() { |
| + test_AsExpression_identifier() async { |
| // SimpleIdentifier TypeName AsExpression |
| - addTestSource('class A {var b; X _c; foo() {var a; (a^ as String).foo();}'); |
| - assertTarget('a as String', '(a as String)'); |
| + await addTestSource( |
| + 'class A {var b; X _c; foo() {var a; (a^ as String).foo();}'); |
| + await assertTarget('a as String', '(a as String)'); |
| } |
| - test_AsExpression_keyword() { |
| + test_AsExpression_keyword() async { |
| // SimpleIdentifier TypeName AsExpression |
| - addTestSource('class A {var b; X _c; foo() {var a; (a ^as String).foo();}'); |
| - assertTarget('as', 'a as String'); |
| + await addTestSource( |
| + 'class A {var b; X _c; foo() {var a; (a ^as String).foo();}'); |
| + await assertTarget('as', 'a as String'); |
| } |
| - test_AsExpression_keyword2() { |
| + test_AsExpression_keyword2() async { |
| // SimpleIdentifier TypeName AsExpression |
| - addTestSource('class A {var b; X _c; foo() {var a; (a a^s String).foo();}'); |
| - assertTarget('as', 'a as String'); |
| + await addTestSource( |
| + 'class A {var b; X _c; foo() {var a; (a a^s String).foo();}'); |
| + await assertTarget('as', 'a as String'); |
| } |
| - test_AsExpression_keyword3() { |
| + test_AsExpression_keyword3() async { |
| // SimpleIdentifier TypeName AsExpression |
| - addTestSource('class A {var b; X _c; foo() {var a; (a as^ String).foo();}'); |
| - assertTarget('as', 'a as String'); |
| + await addTestSource( |
| + 'class A {var b; X _c; foo() {var a; (a as^ String).foo();}'); |
| + await assertTarget('as', 'a as String'); |
| } |
| - test_AsExpression_type() { |
| + test_AsExpression_type() async { |
| // SimpleIdentifier TypeName AsExpression |
| - addTestSource('class A {var b; X _c; foo() {var a; (a as ^String).foo();}'); |
| - assertTarget('String', 'a as String'); |
| + await addTestSource( |
| + 'class A {var b; X _c; foo() {var a; (a as ^String).foo();}'); |
| + await assertTarget('String', 'a as String'); |
| } |
| - test_Block() { |
| + test_Block() async { |
| // Block |
| - addTestSource('main() {^}'); |
| - assertTarget('}', '{}'); |
| + await addTestSource('main() {^}'); |
| + await assertTarget('}', '{}'); |
| } |
| - test_Block_keyword() { |
| - addTestSource('class C { static C get instance => null; } main() {C.in^}'); |
| - assertTarget('in', 'C.in'); |
| + test_Block_keyword() async { |
| + await addTestSource( |
| + 'class C { static C get instance => null; } main() {C.in^}'); |
| + await assertTarget('in', 'C.in'); |
| } |
| - test_Block_keyword2() { |
| - addTestSource('class C { static C get instance => null; } main() {C.i^n}'); |
| - assertTarget('in', 'C.in'); |
| + test_Block_keyword2() async { |
| + await addTestSource( |
| + 'class C { static C get instance => null; } main() {C.i^n}'); |
| + await assertTarget('in', 'C.in'); |
| } |
| - test_FormalParameter_partialType() { |
| + test_FormalParameter_partialType() async { |
| // SimpleIdentifier PrefixedIdentifier TypeName |
| - addTestSource('foo(b.^ f) { }'); |
| - assertTarget('f', 'b.f'); |
| + await addTestSource('foo(b.^ f) { }'); |
| + await assertTarget('f', 'b.f'); |
| } |
| - test_FormalParameter_partialType2() { |
| + test_FormalParameter_partialType2() async { |
| // SimpleIdentifier PrefixedIdentifier TypeName |
| - addTestSource('foo(b.z^ f) { }'); |
| - assertTarget('z', 'b.z'); |
| + await addTestSource('foo(b.z^ f) { }'); |
| + await assertTarget('z', 'b.z'); |
| } |
| - test_FormalParameter_partialType3() { |
| + test_FormalParameter_partialType3() async { |
| // SimpleIdentifier PrefixedIdentifier TypeName |
| - addTestSource('foo(b.^) { }'); |
| - assertTarget('', 'b.'); |
| + await addTestSource('foo(b.^) { }'); |
| + await assertTarget('', 'b.'); |
| } |
| - test_FormalParameterList() { |
| + test_FormalParameterList() async { |
| // Token FormalParameterList FunctionExpression |
| - addTestSource('foo(^) { }'); |
| - assertTarget(')', '()'); |
| + await addTestSource('foo(^) { }'); |
| + await assertTarget(')', '()'); |
| } |
| - test_FunctionDeclaration_inLineComment() { |
| + test_FunctionDeclaration_inLineComment() async { |
| // Comment CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal comment ^ |
| zoo(z) { } String name;'''); |
| - assertTarget('// normal comment ', 'zoo(z) {} String name;'); |
| + await assertTarget('// normal comment ', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inLineComment2() { |
| + test_FunctionDeclaration_inLineComment2() async { |
| // Comment CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal ^comment |
| zoo(z) { } String name;'''); |
| - assertTarget('// normal comment', 'zoo(z) {} String name;'); |
| + await assertTarget('// normal comment', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inLineComment3() { |
| + test_FunctionDeclaration_inLineComment3() async { |
| // Comment CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal comment ^ |
| // normal comment 2 |
| zoo(z) { } String name;'''); |
| - assertTarget('// normal comment ', 'zoo(z) {} String name;'); |
| + await assertTarget('// normal comment ', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inLineComment4() { |
| + test_FunctionDeclaration_inLineComment4() async { |
| // Comment CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal comment |
| // normal comment 2^ |
| zoo(z) { } String name;'''); |
| - assertTarget('// normal comment 2', 'zoo(z) {} String name;'); |
| + await assertTarget('// normal comment 2', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inLineDocComment() { |
| + test_FunctionDeclaration_inLineDocComment() async { |
| // Comment FunctionDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| /// some dartdoc ^ |
| zoo(z) { } String name;'''); |
| - assertTarget('/// some dartdoc ', ''); |
| + await assertTarget('/// some dartdoc ', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_inLineDocComment2() { |
| + test_FunctionDeclaration_inLineDocComment2() async { |
| // Comment FunctionDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| /// some ^dartdoc |
| zoo(z) { } String name;'''); |
| - assertTarget('/// some dartdoc', ''); |
| + await assertTarget('/// some dartdoc', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_inStarComment() { |
| + test_FunctionDeclaration_inStarComment() async { |
| // Comment CompilationUnit |
| - addTestSource('/* ^ */ zoo(z) {} String name;'); |
| - assertTarget('/* */', 'zoo(z) {} String name;'); |
| + await addTestSource('/* ^ */ zoo(z) {} String name;'); |
| + await assertTarget('/* */', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inStarComment2() { |
| + test_FunctionDeclaration_inStarComment2() async { |
| // Comment CompilationUnit |
| - addTestSource('/* *^/ zoo(z) {} String name;'); |
| - assertTarget('/* */', 'zoo(z) {} String name;'); |
| + await addTestSource('/* *^/ zoo(z) {} String name;'); |
| + await assertTarget('/* */', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_inStarDocComment() { |
| + test_FunctionDeclaration_inStarDocComment() async { |
| // Comment FunctionDeclaration CompilationUnit |
| - addTestSource('/** ^ */ zoo(z) { } String name;'); |
| - assertTarget('/** */', ''); |
| + await addTestSource('/** ^ */ zoo(z) { } String name;'); |
| + await assertTarget('/** */', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_inStarDocComment2() { |
| + test_FunctionDeclaration_inStarDocComment2() async { |
| // Comment FunctionDeclaration CompilationUnit |
| - addTestSource('/** *^/ zoo(z) { } String name;'); |
| - assertTarget('/** */', ''); |
| + await addTestSource('/** *^/ zoo(z) { } String name;'); |
| + await assertTarget('/** */', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_returnType() { |
| + test_FunctionDeclaration_returnType() async { |
| // CompilationUnit |
| - addTestSource('^ zoo(z) { } String name;'); |
| - assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| + await addTestSource('^ zoo(z) { } String name;'); |
| + await assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_returnType_afterLineComment() { |
| + test_FunctionDeclaration_returnType_afterLineComment() async { |
| // FunctionDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal comment |
| ^ zoo(z) {} String name;'''); |
| - assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| + await assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_returnType_afterLineComment2() { |
| + test_FunctionDeclaration_returnType_afterLineComment2() async { |
| // FunctionDeclaration CompilationUnit |
| // TOD(danrubel) left align all test source |
| - addTestSource(''' |
| + await addTestSource(''' |
| // normal comment |
| ^ zoo(z) {} String name;'''); |
| - assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| + await assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_returnType_afterLineDocComment() { |
| + test_FunctionDeclaration_returnType_afterLineDocComment() async { |
| // SimpleIdentifier FunctionDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| /// some dartdoc |
| ^ zoo(z) { } String name; '''); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_returnType_afterLineDocComment2() { |
| + test_FunctionDeclaration_returnType_afterLineDocComment2() async { |
| // SimpleIdentifier FunctionDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| /// some dartdoc |
| ^ zoo(z) { } String name;'''); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_returnType_afterStarComment() { |
| + test_FunctionDeclaration_returnType_afterStarComment() async { |
| // CompilationUnit |
| - addTestSource('/* */ ^ zoo(z) { } String name;'); |
| - assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| + await addTestSource('/* */ ^ zoo(z) { } String name;'); |
| + await assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_returnType_afterStarComment2() { |
| + test_FunctionDeclaration_returnType_afterStarComment2() async { |
| // CompilationUnit |
| - addTestSource('/* */^ zoo(z) { } String name;'); |
| - assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| + await addTestSource('/* */^ zoo(z) { } String name;'); |
| + await assertTarget('zoo(z) {}', 'zoo(z) {} String name;'); |
| } |
| - test_FunctionDeclaration_returnType_afterStarDocComment() { |
| + test_FunctionDeclaration_returnType_afterStarDocComment() async { |
| // FunctionDeclaration CompilationUnit |
| - addTestSource('/** */ ^ zoo(z) { } String name;'); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await addTestSource('/** */ ^ zoo(z) { } String name;'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_FunctionDeclaration_returnType_afterStarDocComment2() { |
| + test_FunctionDeclaration_returnType_afterStarDocComment2() async { |
| // FunctionDeclaration CompilationUnit |
| - addTestSource('/** */^ zoo(z) { } String name;'); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await addTestSource('/** */^ zoo(z) { } String name;'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_InstanceCreationExpression_identifier() { |
| + test_InstanceCreationExpression_identifier() async { |
| // InstanceCreationExpression ExpressionStatement Block |
| - addTestSource('class C {foo(){var f; {var x;} new ^C();}}'); |
| - assertTarget('C', 'new C()'); |
| + await addTestSource('class C {foo(){var f; {var x;} new ^C();}}'); |
| + await assertTarget('C', 'new C()'); |
| } |
| - test_InstanceCreationExpression_keyword() { |
| + test_InstanceCreationExpression_keyword() async { |
| // InstanceCreationExpression ExpressionStatement Block |
| - addTestSource('class C {foo(){var f; {var x;} new^ }}'); |
| - assertTarget('new ();', '{var f; {var x;} new ();}'); |
| + await addTestSource('class C {foo(){var f; {var x;} new^ }}'); |
| + await assertTarget('new ();', '{var f; {var x;} new ();}'); |
| } |
| - test_InstanceCreationExpression_keyword2() { |
| + test_InstanceCreationExpression_keyword2() async { |
| // InstanceCreationExpression ExpressionStatement Block |
| - addTestSource('class C {foo(){var f; {var x;} new^ C();}}'); |
| - assertTarget('new C();', '{var f; {var x;} new C();}'); |
| + await addTestSource('class C {foo(){var f; {var x;} new^ C();}}'); |
| + await assertTarget('new C();', '{var f; {var x;} new C();}'); |
| } |
| - test_MapLiteralEntry() { |
| + test_MapLiteralEntry() async { |
| // MapLiteralEntry MapLiteral VariableDeclaration |
| - addTestSource('foo = {^'); |
| - assertTarget(' : ', '{ : }'); |
| + await addTestSource('foo = {^'); |
| + await assertTarget(' : ', '{ : }'); |
| } |
| - test_MapLiteralEntry1() { |
| + test_MapLiteralEntry1() async { |
| // MapLiteralEntry MapLiteral VariableDeclaration |
| - addTestSource('foo = {T^'); |
| - assertTarget('T : ', '{T : }'); |
| + await addTestSource('foo = {T^'); |
| + await assertTarget('T : ', '{T : }'); |
| } |
| - test_MapLiteralEntry2() { |
| + test_MapLiteralEntry2() async { |
| // SimpleIdentifier MapLiteralEntry MapLiteral VariableDeclaration |
| - addTestSource('foo = {7:T^};'); |
| - assertTarget('T', '7 : T'); |
| + await addTestSource('foo = {7:T^};'); |
| + await assertTarget('T', '7 : T'); |
| } |
| - test_MethodDeclaration_inLineComment() { |
| + test_MethodDeclaration_inLineComment() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal comment ^ |
| zoo(z) { } String name; }'''); |
| - assertTarget('// normal comment ', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget( |
| + '// normal comment ', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inLineComment2() { |
| + test_MethodDeclaration_inLineComment2() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal ^comment |
| zoo(z) { } String name; }'''); |
| - assertTarget('// normal comment', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget( |
| + '// normal comment', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inLineComment3() { |
| + test_MethodDeclaration_inLineComment3() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal comment ^ |
| // normal comment 2 |
| zoo(z) { } String name; }'''); |
| - assertTarget('// normal comment ', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget( |
| + '// normal comment ', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inLineComment4() { |
| + test_MethodDeclaration_inLineComment4() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal comment |
| // normal comment 2^ |
| zoo(z) { } String name; }'''); |
| - assertTarget('// normal comment 2', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget( |
| + '// normal comment 2', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inLineDocComment() { |
| + test_MethodDeclaration_inLineDocComment() async { |
| // Comment MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| /// some dartdoc ^ |
| zoo(z) { } String name; }'''); |
| - assertTarget('/// some dartdoc ', ''); |
| + await assertTarget('/// some dartdoc ', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_inLineDocComment2() { |
| + test_MethodDeclaration_inLineDocComment2() async { |
| // Comment MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| /// some ^dartdoc |
| zoo(z) { } String name; }'''); |
| - assertTarget('/// some dartdoc', ''); |
| + await assertTarget('/// some dartdoc', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_inStarComment() { |
| + test_MethodDeclaration_inStarComment() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}'); |
| - assertTarget('/* */', 'class C2 {zoo(z) {} String name;}'); |
| + await addTestSource('class C2 {/* ^ */ zoo(z) {} String name;}'); |
| + await assertTarget('/* */', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inStarComment2() { |
| + test_MethodDeclaration_inStarComment2() async { |
| // Comment ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/* *^/ zoo(z) {} String name;}'); |
| - assertTarget('/* */', 'class C2 {zoo(z) {} String name;}'); |
| + await addTestSource('class C2 {/* *^/ zoo(z) {} String name;}'); |
| + await assertTarget('/* */', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_inStarDocComment() { |
| + test_MethodDeclaration_inStarDocComment() async { |
| // Comment MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }'); |
| - assertTarget('/** */', ''); |
| + await addTestSource('class C2 {/** ^ */ zoo(z) { } String name; }'); |
| + await assertTarget('/** */', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_inStarDocComment2() { |
| + test_MethodDeclaration_inStarDocComment2() async { |
| // Comment MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/** *^/ zoo(z) { } String name; }'); |
| - assertTarget('/** */', ''); |
| + await addTestSource('class C2 {/** *^/ zoo(z) { } String name; }'); |
| + await assertTarget('/** */', ''); |
| expect(target.containingNode is Comment, isTrue); |
| expect(target.containingNode.parent.toSource(), 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_returnType() { |
| + test_MethodDeclaration_returnType() async { |
| // ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {^ zoo(z) { } String name; }'); |
| - assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| + await addTestSource('class C2 {^ zoo(z) { } String name; }'); |
| + await assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_returnType_afterLineComment() { |
| + test_MethodDeclaration_returnType_afterLineComment() async { |
| // MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal comment |
| ^ zoo(z) {} String name;}'''); |
| - assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_returnType_afterLineComment2() { |
| + test_MethodDeclaration_returnType_afterLineComment2() async { |
| // MethodDeclaration ClassDeclaration CompilationUnit |
| // TOD(danrubel) left align all test source |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| // normal comment |
| ^ zoo(z) {} String name;}'''); |
| - assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| + await assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_returnType_afterLineDocComment() { |
| + test_MethodDeclaration_returnType_afterLineDocComment() async { |
| // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| /// some dartdoc |
| ^ zoo(z) { } String name; }'''); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_returnType_afterLineDocComment2() { |
| + test_MethodDeclaration_returnType_afterLineDocComment2() async { |
| // SimpleIdentifier MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource(''' |
| + await addTestSource(''' |
| class C2 { |
| /// some dartdoc |
| ^ zoo(z) { } String name; }'''); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_returnType_afterStarComment() { |
| + test_MethodDeclaration_returnType_afterStarComment() async { |
| // ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }'); |
| - assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| + await addTestSource('class C2 {/* */ ^ zoo(z) { } String name; }'); |
| + await assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_returnType_afterStarComment2() { |
| + test_MethodDeclaration_returnType_afterStarComment2() async { |
| // ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/* */^ zoo(z) { } String name; }'); |
| - assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| + await addTestSource('class C2 {/* */^ zoo(z) { } String name; }'); |
| + await assertTarget('zoo(z) {}', 'class C2 {zoo(z) {} String name;}'); |
| } |
| - test_MethodDeclaration_returnType_afterStarDocComment() { |
| + test_MethodDeclaration_returnType_afterStarDocComment() async { |
| // MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }'); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await addTestSource('class C2 {/** */ ^ zoo(z) { } String name; }'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_MethodDeclaration_returnType_afterStarDocComment2() { |
| + test_MethodDeclaration_returnType_afterStarDocComment2() async { |
| // MethodDeclaration ClassDeclaration CompilationUnit |
| - addTestSource('class C2 {/** */^ zoo(z) { } String name; }'); |
| - assertTarget('zoo', 'zoo(z) {}'); |
| + await addTestSource('class C2 {/** */^ zoo(z) { } String name; }'); |
| + await assertTarget('zoo', 'zoo(z) {}'); |
| } |
| - test_SwitchStatement_c() { |
| + test_SwitchStatement_c() async { |
| // Token('c') SwitchStatement |
| - addTestSource('main() { switch(x) {c^} }'); |
| - assertTarget('}', 'switch (x) {}'); |
| + await addTestSource('main() { switch(x) {c^} }'); |
| + await assertTarget('}', 'switch (x) {}'); |
| } |
| - test_SwitchStatement_c2() { |
| + test_SwitchStatement_c2() async { |
| // Token('c') SwitchStatement |
| - addTestSource('main() { switch(x) { c^ } }'); |
| - assertTarget('}', 'switch (x) {}'); |
| + await addTestSource('main() { switch(x) { c^ } }'); |
| + await assertTarget('}', 'switch (x) {}'); |
| } |
| - test_SwitchStatement_empty() { |
| + test_SwitchStatement_empty() async { |
| // SwitchStatement |
| - addTestSource('main() { switch(x) {^} }'); |
| - assertTarget('}', 'switch (x) {}'); |
| + await addTestSource('main() { switch(x) {^} }'); |
| + await assertTarget('}', 'switch (x) {}'); |
| } |
| - test_SwitchStatement_empty2() { |
| + test_SwitchStatement_empty2() async { |
| // SwitchStatement |
| - addTestSource('main() { switch(x) { ^ } }'); |
| - assertTarget('}', 'switch (x) {}'); |
| + await addTestSource('main() { switch(x) { ^ } }'); |
| + await assertTarget('}', 'switch (x) {}'); |
| } |
| - test_TypeArgumentList() { |
| + test_TypeArgumentList() async { |
| // TypeName TypeArgumentList TypeName |
| - addTestSource('main() { C<^> c; }'); |
| - assertTarget('', '<>'); |
| + await addTestSource('main() { C<^> c; }'); |
| + await assertTarget('', '<>'); |
| } |
| - test_TypeArgumentList2() { |
| + test_TypeArgumentList2() async { |
| // TypeName TypeArgumentList TypeName |
| - addTestSource('main() { C<C^> c; }'); |
| - assertTarget('C', '<C>'); |
| + await addTestSource('main() { C<C^> c; }'); |
| + await assertTarget('C', '<C>'); |
| } |
| - test_VariableDeclaration_lhs_identifier_after() { |
| + test_VariableDeclaration_lhs_identifier_after() async { |
| // VariableDeclaration VariableDeclarationList |
| - addTestSource('main() {int b^ = 1;}'); |
| - assertTarget('b = 1', 'int b = 1'); |
| + await addTestSource('main() {int b^ = 1;}'); |
| + await assertTarget('b = 1', 'int b = 1'); |
| } |
| - test_VariableDeclaration_lhs_identifier_before() { |
| + test_VariableDeclaration_lhs_identifier_before() async { |
| // VariableDeclaration VariableDeclarationList |
| - addTestSource('main() {int ^b = 1;}'); |
| - assertTarget('b = 1', 'int b = 1'); |
| + await addTestSource('main() {int ^b = 1;}'); |
| + await assertTarget('b = 1', 'int b = 1'); |
| } |
| } |