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

Side by Side Diff: pkg/analysis_services/test/correction/source_range_test.dart

Issue 402333006: Implementation of the 'edit.getFixes' API in server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library test.services.correction.source_range; 8 library test.services.correction.source_range;
9 9
10 import 'package:analysis_services/src/correction/source_range.dart'; 10 import 'package:analysis_services/src/correction/source_range.dart';
11 import 'package:analysis_testing/abstract_single_unit.dart';
11 import 'package:analysis_testing/reflective_tests.dart'; 12 import 'package:analysis_testing/reflective_tests.dart';
12 import 'package:analyzer/src/generated/ast.dart'; 13 import 'package:analyzer/src/generated/ast.dart';
13 import 'package:analyzer/src/generated/element.dart'; 14 import 'package:analyzer/src/generated/element.dart';
14 import 'package:analyzer/src/generated/error.dart'; 15 import 'package:analyzer/src/generated/error.dart';
15 import 'package:analyzer/src/generated/parser.dart'; 16 import 'package:analyzer/src/generated/parser.dart';
16 import 'package:analyzer/src/generated/source.dart'; 17 import 'package:analyzer/src/generated/source.dart';
17 import 'package:unittest/unittest.dart' hide isEmpty; 18 import 'package:unittest/unittest.dart' hide isEmpty;
18 19
19 import '../index/abstract_single_unit.dart';
20
21 20
22 main() { 21 main() {
23 groupSep = ' | '; 22 groupSep = ' | ';
24 group('source_range', () { 23 group('source_range', () {
25 runReflectiveTests(SourceRangesTest); 24 runReflectiveTests(SourceRangesTest);
26 }); 25 });
27 } 26 }
28 27
29 28
30 @ReflectiveTestCase() 29 @ReflectiveTestCase()
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 64 }
66 65
67 void test_rangeNodes() { 66 void test_rangeNodes() {
68 resolveTestUnit(' main() {}'); 67 resolveTestUnit(' main() {}');
69 FunctionDeclaration mainFunction = testUnit.declarations[0]; 68 FunctionDeclaration mainFunction = testUnit.declarations[0];
70 SimpleIdentifier mainName = mainFunction.name; 69 SimpleIdentifier mainName = mainFunction.name;
71 FunctionBody mainBody = mainFunction.functionExpression.body; 70 FunctionBody mainBody = mainFunction.functionExpression.body;
72 expect(rangeNodes([mainName, mainBody]), new SourceRange(1, 9)); 71 expect(rangeNodes([mainName, mainBody]), new SourceRange(1, 9));
73 } 72 }
74 73
74 void test_rangeNodes_empty() {
75 resolveTestUnit('main() {}');
76 FunctionDeclaration mainFunction = testUnit.declarations[0];
77 SimpleIdentifier mainName = mainFunction.name;
78 FunctionBody mainBody = mainFunction.functionExpression.body;
79 expect(rangeNodes([]), new SourceRange(0, 0));
80 }
81
82 void test_rangeStartEnd_intInt() {
83 expect(rangeStartEnd(10, 25), new SourceRange(10, 15));
84 }
85
75 void test_rangeStartEnd_nodeNode() { 86 void test_rangeStartEnd_nodeNode() {
76 resolveTestUnit(' main() {}'); 87 resolveTestUnit(' main() {}');
77 FunctionDeclaration mainFunction = testUnit.declarations[0]; 88 FunctionDeclaration mainFunction = testUnit.declarations[0];
78 SimpleIdentifier mainName = mainFunction.name; 89 SimpleIdentifier mainName = mainFunction.name;
79 FunctionBody mainBody = mainFunction.functionExpression.body; 90 FunctionBody mainBody = mainFunction.functionExpression.body;
80 expect(rangeStartEnd(mainName, mainBody), new SourceRange(1, 9)); 91 expect(rangeStartEnd(mainName, mainBody), new SourceRange(1, 9));
81 } 92 }
82 93
83 void test_rangeStartEnd_intInt() { 94 void test_rangeStartLength_int() {
84 expect(rangeStartEnd(10, 25), new SourceRange(10, 15)); 95 expect(rangeStartLength(5, 10), new SourceRange(5, 10));
85 } 96 }
86 97
87 void test_rangeNodes_empty() { 98 void test_rangeStartLength_node() {
88 resolveTestUnit('main() {}'); 99 resolveTestUnit(' main() {}');
89 FunctionDeclaration mainFunction = testUnit.declarations[0]; 100 FunctionDeclaration mainFunction = testUnit.declarations[0];
90 SimpleIdentifier mainName = mainFunction.name; 101 SimpleIdentifier mainName = mainFunction.name;
91 FunctionBody mainBody = mainFunction.functionExpression.body; 102 expect(rangeStartLength(mainName, 10), new SourceRange(1, 10));
92 expect(rangeNodes([]), new SourceRange(0, 0)); 103 }
104
105 void test_rangeStartStart_intInt() {
106 expect(rangeStartStart(10, 25), new SourceRange(10, 15));
93 } 107 }
94 108
95 void test_rangeStartStart_nodeNode() { 109 void test_rangeStartStart_nodeNode() {
96 resolveTestUnit('main() {}'); 110 resolveTestUnit('main() {}');
97 FunctionDeclaration mainFunction = testUnit.declarations[0]; 111 FunctionDeclaration mainFunction = testUnit.declarations[0];
98 SimpleIdentifier mainName = mainFunction.name; 112 SimpleIdentifier mainName = mainFunction.name;
99 FunctionBody mainBody = mainFunction.functionExpression.body; 113 FunctionBody mainBody = mainFunction.functionExpression.body;
100 expect(rangeStartStart(mainName, mainBody), new SourceRange(0, 7)); 114 expect(rangeStartStart(mainName, mainBody), new SourceRange(0, 7));
101 } 115 }
102 116
103 void test_rangeStartStart_intInt() {
104 expect(rangeStartStart(10, 25), new SourceRange(10, 15));
105 }
106
107 void test_rangeStartLength_node() {
108 resolveTestUnit(' main() {}');
109 FunctionDeclaration mainFunction = testUnit.declarations[0];
110 SimpleIdentifier mainName = mainFunction.name;
111 expect(rangeStartLength(mainName, 10), new SourceRange(1, 10));
112 }
113
114 void test_rangeToken() { 117 void test_rangeToken() {
115 resolveTestUnit(' main() {}'); 118 resolveTestUnit(' main() {}');
116 FunctionDeclaration mainFunction = testUnit.declarations[0]; 119 FunctionDeclaration mainFunction = testUnit.declarations[0];
117 SimpleIdentifier mainName = mainFunction.name; 120 SimpleIdentifier mainName = mainFunction.name;
118 expect(rangeToken(mainName.beginToken), new SourceRange(1, 4)); 121 expect(rangeToken(mainName.beginToken), new SourceRange(1, 4));
119 } 122 }
120
121 void test_rangeStartLength_int() {
122 expect(rangeStartLength(5, 10), new SourceRange(5, 10));
123 }
124 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698