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

Side by Side Diff: pkg/analysis_server/test/services/completion/completion_target_test.dart

Issue 2394683006: Switch analysis_server to use 'package:test'. (Closed)
Patch Set: Created 4 years, 2 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.services.completion.target; 5 library test.services.completion.target;
6 6
7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart'; 7 import 'package:analysis_server/src/provisional/completion/dart/completion_targe t.dart';
8 import 'package:analyzer/dart/ast/ast.dart'; 8 import 'package:analyzer/dart/ast/ast.dart';
9 import 'package:analyzer/src/generated/source.dart'; 9 import 'package:analyzer/src/generated/source.dart';
10 import 'package:test/test.dart';
10 import 'package:test_reflective_loader/test_reflective_loader.dart'; 11 import 'package:test_reflective_loader/test_reflective_loader.dart';
11 import 'package:unittest/unittest.dart';
12 12
13 import '../../abstract_context.dart'; 13 import '../../abstract_context.dart';
14 import '../../utils.dart'; 14 import '../../utils.dart';
15 15
16 main() { 16 main() {
17 initializeTestEnvironment(); 17 initializeTestEnvironment();
18 defineReflectiveTests(CompletionTargetTest); 18 defineReflectiveSuite(() {
19 defineReflectiveTests(CompletionTargetTest);
20 });
19 } 21 }
20 22
21 @reflectiveTest 23 @reflectiveTest
22 class CompletionTargetTest extends AbstractContextTest { 24 class CompletionTargetTest extends AbstractContextTest {
23 Source testSource; 25 Source testSource;
24 int completionOffset; 26 int completionOffset;
25 CompletionTarget target; 27 CompletionTarget target;
26 28
27 void addTestSource(String content) { 29 void addTestSource(String content) {
28 expect(completionOffset, isNull, reason: 'Call addTestSource exactly once'); 30 expect(completionOffset, isNull, reason: 'Call addTestSource exactly once');
29 completionOffset = content.indexOf('^'); 31 completionOffset = content.indexOf('^');
30 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 32 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
31 int nextOffset = content.indexOf('^', completionOffset + 1); 33 int nextOffset = content.indexOf('^', completionOffset + 1);
32 expect(nextOffset, equals(-1), reason: 'too many ^'); 34 expect(nextOffset, equals(-1), reason: 'too many ^');
33 content = content.substring(0, completionOffset) + 35 content = content.substring(0, completionOffset) +
34 content.substring(completionOffset + 1); 36 content.substring(completionOffset + 1);
35 testSource = addSource('/test.dart', content); 37 testSource = addSource('/test.dart', content);
36 CompilationUnit unit = context.parseCompilationUnit(testSource); 38 CompilationUnit unit = context.parseCompilationUnit(testSource);
37 target = new CompletionTarget.forOffset(unit, completionOffset); 39 target = new CompletionTarget.forOffset(unit, completionOffset);
38 } 40 }
39 41
40 void assertTarget(entityText, nodeText, 42 void assertTarget(entityText, nodeText,
41 {int argIndex: null, bool isFunctionalArgument: false}) { 43 {int argIndex: null, bool isFunctionalArgument: false}) {
42 void assertCommon() { 44 void assertCommon() {
43 expect(target.entity.toString(), entityText, reason: 'entity'); 45 expect(target.entity.toString(), entityText, reason: 'entity');
44 expect(target.containingNode.toString(), nodeText, 46 expect(target.containingNode.toString(), nodeText,
45 reason: 'containingNode'); 47 reason: 'containingNode');
46 expect(target.argIndex, argIndex, reason: 'argIndex'); 48 expect(target.argIndex, argIndex, reason: 'argIndex');
47 } 49 }
50
48 // Assert with parsed unit 51 // Assert with parsed unit
49 assertCommon(); 52 assertCommon();
50 CompilationUnit unit = 53 CompilationUnit unit =
51 context.resolveCompilationUnit2(testSource, testSource); 54 context.resolveCompilationUnit2(testSource, testSource);
52 target = new CompletionTarget.forOffset(unit, completionOffset); 55 target = new CompletionTarget.forOffset(unit, completionOffset);
53 // Assert more with resolved unit 56 // Assert more with resolved unit
54 assertCommon(); 57 assertCommon();
55 expect(target.isFunctionalArgument(), isFunctionalArgument); 58 expect(target.isFunctionalArgument(), isFunctionalArgument);
56 } 59 }
57 60
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 addTestSource('main() {int b^ = 1;}'); 565 addTestSource('main() {int b^ = 1;}');
563 assertTarget('b = 1', 'int b = 1'); 566 assertTarget('b = 1', 'int b = 1');
564 } 567 }
565 568
566 test_VariableDeclaration_lhs_identifier_before() { 569 test_VariableDeclaration_lhs_identifier_before() {
567 // VariableDeclaration VariableDeclarationList 570 // VariableDeclaration VariableDeclarationList
568 addTestSource('main() {int ^b = 1;}'); 571 addTestSource('main() {int ^b = 1;}');
569 assertTarget('b = 1', 'int b = 1'); 572 assertTarget('b = 1', 'int b = 1');
570 } 573 }
571 } 574 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698