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

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

Issue 1347943006: Replace NameElement with IndexableName. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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/index_core.dart'; 7 import 'package:analysis_server/analysis/index/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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 IndexableObject indexable = new IndexableElement(element); 245 IndexableObject indexable = new IndexableElement(element);
246 int id1 = codec.encode1(indexable); 246 int id1 = codec.encode1(indexable);
247 int id2 = codec.encode2(indexable); 247 int id2 = codec.encode2(indexable);
248 int id3 = codec.encode3(indexable); 248 int id3 = codec.encode3(indexable);
249 expect(id1, isNonNegative); 249 expect(id1, isNonNegative);
250 expect(id2, element.nameOffset); 250 expect(id2, element.nameOffset);
251 expect(id3, IndexableElementKind.forElement(element).index); 251 expect(id3, IndexableElementKind.forElement(element).index);
252 validateDecode(id1, id2, id3, element); 252 validateDecode(id1, id2, id3, element);
253 } 253 }
254 254
255 void test_encode_IndexableName() {
256 IndexableName indexable = new IndexableName('test');
257 int id1 = codec.encode1(indexable);
258 int id2 = codec.encode2(indexable);
259 int id3 = codec.encode3(indexable);
260 expect(id1, -1);
261 expect(id2, isNonNegative);
262 expect(id3, IndexableNameKind.INSTANCE.index);
263 }
264
255 void test_encode_LibraryElement() { 265 void test_encode_LibraryElement() {
256 resolveTestUnit(''' 266 resolveTestUnit('''
257 class A { 267 class A {
258 test() {} 268 test() {}
259 } 269 }
260 '''); 270 ''');
261 Element element = testLibraryElement; 271 Element element = testLibraryElement;
262 IndexableObject indexable = new IndexableElement(element); 272 IndexableObject indexable = new IndexableElement(element);
263 int id1 = codec.encode1(indexable); 273 int id1 = codec.encode1(indexable);
264 int id2 = codec.encode2(indexable); 274 int id2 = codec.encode2(indexable);
(...skipping 14 matching lines...) Expand all
279 IndexableObject indexable = new IndexableElement(element); 289 IndexableObject indexable = new IndexableElement(element);
280 int id1 = codec.encode1(indexable); 290 int id1 = codec.encode1(indexable);
281 int id2 = codec.encode2(indexable); 291 int id2 = codec.encode2(indexable);
282 int id3 = codec.encode3(indexable); 292 int id3 = codec.encode3(indexable);
283 expect(id1, isNonNegative); 293 expect(id1, isNonNegative);
284 expect(id2, element.nameOffset); 294 expect(id2, element.nameOffset);
285 expect(id3, IndexableElementKind.forElement(element).index); 295 expect(id3, IndexableElementKind.forElement(element).index);
286 validateDecode(id1, id2, id3, element); 296 validateDecode(id1, id2, id3, element);
287 } 297 }
288 298
289 void test_encode_NameElement() {
290 Element element = new NameElement('test');
291 IndexableObject indexable = new IndexableElement(element);
292 int id1 = codec.encode1(indexable);
293 int id2 = codec.encode2(indexable);
294 int id3 = codec.encode3(indexable);
295 expect(id1, -1);
296 expect(id2, isNonNegative);
297 expect(id3, IndexableElementKind.forElement(element).index);
298 }
299
300 void test_encode_nullLibraryElement() { 299 void test_encode_nullLibraryElement() {
301 resolveTestUnit(''' 300 resolveTestUnit('''
302 test() {} 301 test() {}
303 '''); 302 ''');
304 Element element = findElement('test'); 303 Element element = findElement('test');
305 IndexableObject indexable = new IndexableElement(element); 304 IndexableObject indexable = new IndexableElement(element);
306 int id1 = codec.encode1(indexable); 305 int id1 = codec.encode1(indexable);
307 int id2 = codec.encode2(indexable); 306 int id2 = codec.encode2(indexable);
308 int id3 = codec.encode3(indexable); 307 int id3 = codec.encode3(indexable);
309 context.setContents(testSource, ''); 308 context.setContents(testSource, '');
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 class _StringCodecTest { 398 class _StringCodecTest {
400 StringCodec codec = new StringCodec(); 399 StringCodec codec = new StringCodec();
401 400
402 void test_all() { 401 void test_all() {
403 int idA = codec.encode('aaa'); 402 int idA = codec.encode('aaa');
404 int idB = codec.encode('bbb'); 403 int idB = codec.encode('bbb');
405 expect(codec.decode(idA), 'aaa'); 404 expect(codec.decode(idA), 'aaa');
406 expect(codec.decode(idB), 'bbb'); 405 expect(codec.decode(idB), 'bbb');
407 } 406 }
408 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698