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

Side by Side Diff: pkg/analysis_services/test/index/local_index_test.dart

Issue 377053002: Tests for LocalIndex and Dart index contributor. (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 library test.services.src.index.local_index; 5 library test.services.src.index.local_index;
6 6
7 //import 'dart:async'; 7 import 'dart:async';
8 //import 'dart:io' show Directory; 8
9 // 9 import 'package:analysis_services/index/index.dart';
10 //import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analysis_services/index/local_memory_index.dart';
11 //import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analysis_services/src/index/local_index.dart';
12 //import 'package:analyzer/src/generated/html.dart'; 12 import 'package:analysis_testing/abstract_context.dart';
13 //import 'package:analyzer/src/generated/source_io.dart'; 13 import 'package:analysis_testing/reflective_tests.dart';
14 //import 'package:unittest/unittest.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
15 // 15 import 'package:analyzer/src/generated/html.dart';
16 //import '../reflective_tests.dart'; 16 import 'package:analyzer/src/generated/source_io.dart';
17 //import 'store/memory_node_manager.dart'; 17 import 'package:unittest/unittest.dart';
18 //import 'store/single_source_container.dart'; 18
19 //import 'package:analyzer/src/index/local_index.dart'; 19 import 'store/single_source_container.dart';
20 //import 'package:analyzer/index/index.dart';
21 20
22 21
23 main() { 22 main() {
24 // groupSep = ' | '; 23 groupSep = ' | ';
25 // group('LocalIndex', () { 24 group('LocalIndex', () {
26 //// runReflectiveTests(LocalIndexTest); 25 runReflectiveTests(LocalIndexTest);
27 // }); 26 });
28 } 27 }
29 28
30 29
31 //void _assertElementNames(List<Location> locations, List expected) { 30 void _assertElementNames(List<Location> locations, List expected) {
32 // expect(_toElementNames(locations), unorderedEquals(expected)); 31 expect(_toElementNames(locations), unorderedEquals(expected));
33 //} 32 }
34 //
35 //
36 //Iterable<String> _toElementNames(List<Location> locations) {
37 // return locations.map((loc) => loc.element.name);
38 //}
39 33
40 34
41 /** 35 Iterable<String> _toElementNames(List<Location> locations) {
42 * TODO(scheglov) Decide what what to do with AbstractContextTest, resource and 36 return locations.map((loc) => loc.element.name);
43 * all other testing infrastructure existing in Server, but not in Engine. 37 }
44 */ 38
45 class LocalIndexTest {} 39
46 //@ReflectiveTestCase() 40 @ReflectiveTestCase()
47 //class LocalIndexTest extends AbstractContextTest { 41 class LocalIndexTest extends AbstractContextTest {
48 // Directory indexDirectory; 42 LocalIndex index;
49 // LocalIndex index; 43
50 // 44 void setUp() {
51 // void setUp() { 45 super.setUp();
52 // super.setUp(); 46 index = createLocalMemoryIndex();
53 // // prepare Index 47 }
54 // indexDirectory = Directory.systemTemp.createTempSync( 48
55 // 'AnalysisServer_index'); 49 void tearDown() {
56 // index = new LocalIndex(new MemoryNodeManager()); 50 super.tearDown();
57 // } 51 index = null;
58 // 52 }
59 // void tearDown() { 53
60 // super.tearDown(); 54 Future test_clear() {
61 // indexDirectory.delete(recursive: true); 55 _indexTest('main() {}');
62 // index = null; 56 return _getDefinedFunctions().then((locations) {
63 // } 57 _assertElementNames(locations, ['main']);
64 // 58 // clear
65 // Future test_clear() { 59 index.clear();
66 // _indexTest('main() {}'); 60 return _getDefinedFunctions().then((locations) {
67 // return _getDefinedFunctions().then((locations) { 61 expect(locations, isEmpty);
68 // _assertElementNames(locations, ['main']); 62 });
69 // // clear 63 });
70 // index.clear(); 64 }
71 // return _getDefinedFunctions().then((locations) { 65
72 // expect(locations, isEmpty); 66 void test_indexHtmlUnit_nullUnit() {
73 // }); 67 index.indexHtmlUnit(context, null);
74 // }); 68 }
75 // } 69
76 // 70 void test_indexHtmlUnit_nullUnitElement() {
77 // void test_indexHtmlUnit_nullUnit() { 71 HtmlUnit unit = new HtmlUnit(null, [], null);
78 // index.indexHtmlUnit(context, null); 72 index.indexHtmlUnit(context, unit);
79 // } 73 }
80 // 74
81 // void test_indexHtmlUnit_nullUnitElement() { 75 Future test_indexUnit() {
82 // HtmlUnit unit = new HtmlUnit(null, [], null); 76 _indexTest('main() {}');
83 // index.indexHtmlUnit(context, unit); 77 return _getDefinedFunctions().then((locations) {
84 // } 78 _assertElementNames(locations, ['main']);
85 // 79 });
86 // Future test_indexUnit() { 80 }
87 // _indexTest('main() {}'); 81
88 // return _getDefinedFunctions().then((locations) { 82 void test_indexUnit_nullUnit() {
89 // _assertElementNames(locations, ['main']); 83 index.indexUnit(context, null);
90 // }); 84 }
91 // } 85
92 // 86 void test_indexUnit_nullUnitElement() {
93 // void test_indexUnit_nullUnit() { 87 CompilationUnit unit = new CompilationUnit(null, null, [], [], null);
94 // index.indexUnit(context, null); 88 index.indexUnit(context, unit);
95 // } 89 }
96 // 90
97 // void test_indexUnit_nullUnitElement() { 91 Future test_removeContext() {
98 // CompilationUnit unit = new CompilationUnit(null, null, [], [], null); 92 _indexTest('main() {}');
99 // index.indexUnit(context, unit); 93 return _getDefinedFunctions().then((locations) {
100 // } 94 // OK, there is a location
101 // 95 _assertElementNames(locations, ['main']);
102 // Future test_removeContext() { 96 // remove context
103 // _indexTest('main() {}'); 97 index.removeContext(context);
104 // return _getDefinedFunctions().then((locations) { 98 return _getDefinedFunctions().then((locations) {
105 // // OK, there is a location 99 expect(locations, isEmpty);
106 // _assertElementNames(locations, ['main']); 100 });
107 // // remove context 101 });
108 // index.removeContext(context); 102 }
109 // return _getDefinedFunctions().then((locations) { 103
110 // expect(locations, isEmpty); 104 Future test_removeSource() {
111 // }); 105 Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}');
112 // }); 106 _indexLibraryUnit('/testB.dart', 'fb() {}');
113 // } 107 return _getDefinedFunctions().then((locations) {
114 // 108 // OK, there are 2 functions
115 // Future test_removeSource() { 109 _assertElementNames(locations, ['fa', 'fb']);
116 // Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}'); 110 // remove source
117 // _indexLibraryUnit('/testB.dart', 'fb() {}'); 111 index.removeSource(context, sourceA);
118 // return _getDefinedFunctions().then((locations) { 112 return _getDefinedFunctions().then((locations) {
119 // // OK, there are 2 functions 113 _assertElementNames(locations, ['fb']);
120 // _assertElementNames(locations, ['fa', 'fb']); 114 });
121 // // remove source 115 });
122 // index.removeSource(context, sourceA); 116 }
123 // return _getDefinedFunctions().then((locations) { 117
124 // _assertElementNames(locations, ['fb']); 118 Future test_removeSources() {
125 // }); 119 Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}');
126 // }); 120 _indexLibraryUnit('/testB.dart', 'fb() {}');
127 // } 121 return _getDefinedFunctions().then((locations) {
128 // 122 // OK, there are 2 functions
129 // Future test_removeSources() { 123 _assertElementNames(locations, ['fa', 'fb']);
130 // Source sourceA = _indexLibraryUnit('/testA.dart', 'fa() {}'); 124 // remove source(s)
131 // _indexLibraryUnit('/testB.dart', 'fb() {}'); 125 index.removeSources(context, new SingleSourceContainer(sourceA));
132 // return _getDefinedFunctions().then((locations) { 126 return _getDefinedFunctions().then((locations) {
133 // // OK, there are 2 functions 127 _assertElementNames(locations, ['fb']);
134 // _assertElementNames(locations, ['fa', 'fb']); 128 });
135 // // remove source(s) 129 });
136 // index.removeSources(context, new SingleSourceContainer(sourceA)); 130 }
137 // return _getDefinedFunctions().then((locations) { 131
138 // _assertElementNames(locations, ['fb']); 132 void test_statistics() {
139 // }); 133 expect(index.statistics, '[0 locations, 0 sources, 0 names]');
140 // }); 134 }
141 // } 135
142 // 136 Future<List<Location>> _getDefinedFunctions() {
143 // void test_statistics() { 137 return index.getRelationships(UniverseElement.INSTANCE,
144 // expect(index.statistics, '[0 locations, 0 sources, 0 names]'); 138 IndexConstants.DEFINES_FUNCTION);
145 // } 139 }
146 // 140
147 // Future<List<Location>> _getDefinedFunctions() { 141 Source _indexLibraryUnit(String path, String content) {
148 // return index.getRelationshipsAsync(UniverseElement.INSTANCE, 142 Source source = addSource(path, content);
149 // IndexConstants.DEFINES_FUNCTION); 143 CompilationUnit dartUnit = resolveLibraryUnit(source);
150 // } 144 index.indexUnit(context, dartUnit);
151 // 145 return source;
152 // Source _indexLibraryUnit(String path, String content) { 146 }
153 // Source source = addSource(path, content); 147
154 // CompilationUnit dartUnit = resolveLibraryUnit(source); 148 void _indexTest(String content) {
155 // index.indexUnit(context, dartUnit); 149 _indexLibraryUnit('/test.dart', content);
156 // return source; 150 }
157 // } 151 }
158 //
159 // void _indexTest(String content) {
160 // _indexLibraryUnit('/test.dart', content);
161 // }
162 //}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698