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

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

Issue 484733003: Import analysis_services.dart into analysis_server.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.services.correction.source_range;
6
7 import 'package:analysis_services/src/correction/source_range.dart';
8 import 'package:analysis_testing/abstract_single_unit.dart';
9 import 'package:analysis_testing/reflective_tests.dart';
10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/parser.dart';
14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:unittest/unittest.dart';
16
17
18 main() {
19 groupSep = ' | ';
20 runReflectiveTests(SourceRangesTest);
21 }
22
23
24 @ReflectiveTestCase()
25 class SourceRangesTest extends AbstractSingleUnitTest {
26 void test_rangeElementName() {
27 resolveTestUnit('class ABC {}');
28 Element element = findElement('ABC');
29 expect(rangeElementName(element), new SourceRange(6, 3));
30 }
31
32 void test_rangeEndEnd_nodeNode() {
33 resolveTestUnit('main() {}');
34 FunctionDeclaration mainFunction = testUnit.declarations[0];
35 SimpleIdentifier mainName = mainFunction.name;
36 FunctionBody mainBody = mainFunction.functionExpression.body;
37 expect(rangeEndEnd(mainName, mainBody), new SourceRange(4, 5));
38 }
39
40 void test_rangeEndStart_nodeNode() {
41 resolveTestUnit('main() {}');
42 FunctionDeclaration mainFunction = testUnit.declarations[0];
43 SimpleIdentifier mainName = mainFunction.name;
44 FunctionBody mainBody = mainFunction.functionExpression.body;
45 expect(rangeEndStart(mainName, mainBody), new SourceRange(4, 3));
46 }
47
48 void test_rangeError() {
49 AnalysisError error =
50 new AnalysisError.con2(null, 10, 5, ParserErrorCode.CONST_CLASS, []);
51 expect(rangeError(error), new SourceRange(10, 5));
52 }
53
54 void test_rangeNode() {
55 resolveTestUnit('main() {}');
56 FunctionDeclaration mainFunction = testUnit.declarations[0];
57 SimpleIdentifier mainName = mainFunction.name;
58 expect(rangeNode(mainName), new SourceRange(0, 4));
59 }
60
61 void test_rangeNodes() {
62 resolveTestUnit(' main() {}');
63 FunctionDeclaration mainFunction = testUnit.declarations[0];
64 SimpleIdentifier mainName = mainFunction.name;
65 FunctionBody mainBody = mainFunction.functionExpression.body;
66 expect(rangeNodes([mainName, mainBody]), new SourceRange(1, 9));
67 }
68
69 void test_rangeNodes_empty() {
70 resolveTestUnit('main() {}');
71 FunctionDeclaration mainFunction = testUnit.declarations[0];
72 SimpleIdentifier mainName = mainFunction.name;
73 FunctionBody mainBody = mainFunction.functionExpression.body;
74 expect(rangeNodes([]), new SourceRange(0, 0));
75 }
76
77 void test_rangeStartEnd_intInt() {
78 expect(rangeStartEnd(10, 25), new SourceRange(10, 15));
79 }
80
81 void test_rangeStartEnd_nodeNode() {
82 resolveTestUnit(' main() {}');
83 FunctionDeclaration mainFunction = testUnit.declarations[0];
84 SimpleIdentifier mainName = mainFunction.name;
85 FunctionBody mainBody = mainFunction.functionExpression.body;
86 expect(rangeStartEnd(mainName, mainBody), new SourceRange(1, 9));
87 }
88
89 void test_rangeStartLength_int() {
90 expect(rangeStartLength(5, 10), new SourceRange(5, 10));
91 }
92
93 void test_rangeStartLength_node() {
94 resolveTestUnit(' main() {}');
95 FunctionDeclaration mainFunction = testUnit.declarations[0];
96 SimpleIdentifier mainName = mainFunction.name;
97 expect(rangeStartLength(mainName, 10), new SourceRange(1, 10));
98 }
99
100 void test_rangeStartStart_intInt() {
101 expect(rangeStartStart(10, 25), new SourceRange(10, 15));
102 }
103
104 void test_rangeStartStart_nodeNode() {
105 resolveTestUnit('main() {}');
106 FunctionDeclaration mainFunction = testUnit.declarations[0];
107 SimpleIdentifier mainName = mainFunction.name;
108 FunctionBody mainBody = mainFunction.functionExpression.body;
109 expect(rangeStartStart(mainName, mainBody), new SourceRange(0, 7));
110 }
111
112 void test_rangeToken() {
113 resolveTestUnit(' main() {}');
114 FunctionDeclaration mainFunction = testUnit.declarations[0];
115 SimpleIdentifier mainName = mainFunction.name;
116 expect(rangeToken(mainName.beginToken), new SourceRange(1, 4));
117 }
118 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698