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

Side by Side Diff: pkg/analysis_server/test/services/index/store/codec_test.dart

Issue 1378843003: Remove the 'name' and 'length' getters from IndexableObject. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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.src.index.store.codec; 5 library test.services.src.index.store.codec;
6 6
7 import 'package:analysis_server/analysis/index_core.dart'; 7 import 'package:analysis_server/analysis/index_core.dart';
8 import 'package:analysis_server/src/services/index/index.dart'; 8 import 'package:analysis_server/src/services/index/index.dart';
9 import 'package:analysis_server/src/services/index/indexable_element.dart'; 9 import 'package:analysis_server/src/services/index/indexable_element.dart';
10 import 'package:analysis_server/src/services/index/store/codec.dart'; 10 import 'package:analysis_server/src/services/index/store/codec.dart';
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 '''); 86 ''');
87 // defining unit 87 // defining unit
88 { 88 {
89 Element element = testLibraryElement.definingCompilationUnit; 89 Element element = testLibraryElement.definingCompilationUnit;
90 expect(element.source.fullName, '/test.dart'); 90 expect(element.source.fullName, '/test.dart');
91 IndexableObject indexable = new IndexableElement(element); 91 IndexableObject indexable = new IndexableElement(element);
92 int id1 = codec.encode1(indexable); 92 int id1 = codec.encode1(indexable);
93 int id2 = codec.encode2(indexable); 93 int id2 = codec.encode2(indexable);
94 int id3 = codec.encode3(indexable); 94 int id3 = codec.encode3(indexable);
95 expect(id1, isNonNegative); 95 expect(id1, isNonNegative);
96 expect(id2, isNonNegative); 96 expect(id2, -1);
97 expect(id3, IndexableElementKind.forElement(element).index); 97 expect(id3, IndexableElementKind.forElement(element).index);
98 validateDecode(id1, id2, id3, element); 98 validateDecode(id1, id2, id3, element);
99 } 99 }
100 // part 100 // part
101 { 101 {
102 Element element = testLibraryElement.parts[0]; 102 Element element = testLibraryElement.parts[0];
103 expect(element.source.fullName, '/my_part.dart'); 103 expect(element.source.fullName, '/my_part.dart');
104 IndexableObject indexable = new IndexableElement(element); 104 IndexableObject indexable = new IndexableElement(element);
105 int id1 = codec.encode1(indexable); 105 int id1 = codec.encode1(indexable);
106 int id2 = codec.encode2(indexable); 106 int id2 = codec.encode2(indexable);
107 int id3 = codec.encode3(indexable); 107 int id3 = codec.encode3(indexable);
108 expect(id1, isNonNegative); 108 expect(id1, isNonNegative);
109 expect(id2, isNonNegative); 109 expect(id2, -1);
110 expect(id3, IndexableElementKind.forElement(element).index); 110 expect(id3, IndexableElementKind.forElement(element).index);
111 validateDecode(id1, id2, id3, element); 111 validateDecode(id1, id2, id3, element);
112 } 112 }
113 } 113 }
114 114
115 void test_encode_ConstructorElement_default_real() { 115 void test_encode_ConstructorElement_default_real() {
116 resolveTestUnit(''' 116 resolveTestUnit('''
117 class A { 117 class A {
118 A(); 118 A();
119 } 119 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 253 }
254 254
255 void test_encode_IndexableName() { 255 void test_encode_IndexableName() {
256 IndexableName indexable = new IndexableName('test'); 256 IndexableName indexable = new IndexableName('test');
257 int id1 = codec.encode1(indexable); 257 int id1 = codec.encode1(indexable);
258 int id2 = codec.encode2(indexable); 258 int id2 = codec.encode2(indexable);
259 int id3 = codec.encode3(indexable); 259 int id3 = codec.encode3(indexable);
260 expect(id1, -1); 260 expect(id1, -1);
261 expect(id2, isNonNegative); 261 expect(id2, isNonNegative);
262 expect(id3, IndexableNameKind.INSTANCE.index); 262 expect(id3, IndexableNameKind.INSTANCE.index);
263 expect(codec.decode(context, id1, id2, id3), indexable);
263 } 264 }
264 265
265 void test_encode_LibraryElement() { 266 void test_encode_LibraryElement() {
266 resolveTestUnit(''' 267 resolveTestUnit('''
267 class A { 268 class A {
268 test() {} 269 test() {}
269 } 270 }
270 '''); 271 ''');
271 Element element = testLibraryElement; 272 Element element = testLibraryElement;
272 IndexableObject indexable = new IndexableElement(element); 273 IndexableObject indexable = new IndexableElement(element);
273 int id1 = codec.encode1(indexable); 274 int id1 = codec.encode1(indexable);
274 int id2 = codec.encode2(indexable); 275 int id2 = codec.encode2(indexable);
275 int id3 = codec.encode3(indexable); 276 int id3 = codec.encode3(indexable);
276 expect(id1, isNonNegative); 277 expect(id1, isNonNegative);
277 expect(id2, isNonNegative); 278 expect(id2, -1);
278 expect(id3, IndexableElementKind.forElement(element).index); 279 expect(id3, IndexableElementKind.forElement(element).index);
279 validateDecode(id1, id2, id3, element); 280 validateDecode(id1, id2, id3, element);
280 } 281 }
281 282
282 void test_encode_MethodElement() { 283 void test_encode_MethodElement() {
283 resolveTestUnit(''' 284 resolveTestUnit('''
284 class A { 285 class A {
285 test() {} 286 test() {}
286 } 287 }
287 '''); 288 ''');
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 class _StringCodecTest { 399 class _StringCodecTest {
399 StringCodec codec = new StringCodec(); 400 StringCodec codec = new StringCodec();
400 401
401 void test_all() { 402 void test_all() {
402 int idA = codec.encode('aaa'); 403 int idA = codec.encode('aaa');
403 int idB = codec.encode('bbb'); 404 int idB = codec.encode('bbb');
404 expect(codec.decode(idA), 'aaa'); 405 expect(codec.decode(idA), 'aaa');
405 expect(codec.decode(idB), 'bbb'); 406 expect(codec.decode(idB), 'bbb');
406 } 407 }
407 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698