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

Unified Diff: pkg/analysis_server/test/index/store/codec_test.dart

Issue 365193004: Move Index and IndexStore implementations into Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/index/store/codec_test.dart
diff --git a/pkg/analysis_server/test/index/store/codec_test.dart b/pkg/analysis_server/test/index/store/codec_test.dart
deleted file mode 100644
index 5d5262f3484283d08e2c82af5dca3983c4da6e17..0000000000000000000000000000000000000000
--- a/pkg/analysis_server/test/index/store/codec_test.dart
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-library test.index.store.codec;
-
-import 'package:analysis_server/src/index/store/codec.dart';
-import 'package:analyzer/src/generated/element.dart';
-import 'package:analyzer/src/generated/engine.dart';
-import 'package:analyzer/src/generated/index.dart';
-import 'package:typed_mock/typed_mock.dart';
-import 'package:unittest/unittest.dart';
-
-import '../../reflective_tests.dart';
-import 'typed_mocks.dart';
-
-
-main() {
- groupSep = ' | ';
- group('ContextCodec', () {
- runReflectiveTests(_ContextCodecTest);
- });
- group('ElementCodec', () {
- runReflectiveTests(_ElementCodecTest);
- });
- group('RelationshipCodec', () {
- runReflectiveTests(_RelationshipCodecTest);
- });
- group('StringCodec', () {
- runReflectiveTests(_StringCodecTest);
- });
-}
-
-
-@ReflectiveTestCase()
-class _ContextCodecTest {
- ContextCodec codec = new ContextCodec();
-
- void test_encode_decode() {
- AnalysisContext contextA = new MockAnalysisContext('contextA');
- AnalysisContext contextB = new MockAnalysisContext('contextB');
- int idA = codec.encode(contextA);
- int idB = codec.encode(contextB);
- expect(idA, codec.encode(contextA));
- expect(idB, codec.encode(contextB));
- expect(codec.decode(idA), contextA);
- expect(codec.decode(idB), contextB);
- }
-
- void test_remove() {
- // encode
- {
- AnalysisContext context = new MockAnalysisContext('context');
- // encode
- int id = codec.encode(context);
- expect(id, 0);
- expect(codec.decode(id), context);
- // remove
- codec.remove(context);
- expect(codec.decode(id), isNull);
- }
- // encode again
- {
- AnalysisContext context = new MockAnalysisContext('context');
- // encode
- int id = codec.encode(context);
- expect(id, 1);
- expect(codec.decode(id), context);
- }
- }
-}
-
-
-@ReflectiveTestCase()
-class _ElementCodecTest {
- ElementCodec codec;
- AnalysisContext context = new MockAnalysisContext('context');
- StringCodec stringCodec = new StringCodec();
-
- void setUp() {
- codec = new ElementCodec(stringCodec);
- }
-
- void test_localLocalVariable() {
- {
- Element element = new MockElement();
- ElementLocation location = new ElementLocationImpl.con3(['main', 'foo@1',
- 'bar@2']);
- when(context.getElement(location)).thenReturn(element);
- when(element.location).thenReturn(location);
- int id = codec.encode(element);
- expect(codec.decode(context, id), element);
- }
- {
- Element element = new MockElement();
- ElementLocation location = new ElementLocationImpl.con3(['main', 'foo@10',
- 'bar@20']);
- when(context.getElement(location)).thenReturn(element);
- when(element.location).thenReturn(location);
- int id = codec.encode(element);
- expect(codec.decode(context, id), element);
- }
- // check strings, "foo" as a single string, no "foo@1" or "foo@10"
- expect(stringCodec.nameToIndex, hasLength(3));
- expect(stringCodec.nameToIndex, containsPair('main', 0));
- expect(stringCodec.nameToIndex, containsPair('foo', 1));
- expect(stringCodec.nameToIndex, containsPair('bar', 2));
- }
-
- void test_localVariable() {
- {
- Element element = new MockElement();
- ElementLocation location = new ElementLocationImpl.con3(['main',
- 'foo@42']);
- when(context.getElement(location)).thenReturn(element);
- when(element.location).thenReturn(location);
- int id = codec.encode(element);
- expect(codec.decode(context, id), element);
- }
- {
- Element element = new MockElement();
- ElementLocation location = new ElementLocationImpl.con3(['main',
- 'foo@4200']);
- when(context.getElement(location)).thenReturn(element);
- when(element.location).thenReturn(location);
- int id = codec.encode(element);
- expect(codec.decode(context, id), element);
- }
- // check strings, "foo" as a single string, no "foo@42" or "foo@4200"
- expect(stringCodec.nameToIndex, hasLength(2));
- expect(stringCodec.nameToIndex, containsPair('main', 0));
- expect(stringCodec.nameToIndex, containsPair('foo', 1));
- }
-
- void test_notLocal() {
- Element element = new MockElement();
- ElementLocation location = new ElementLocationImpl.con3(['foo', 'bar']);
- when(element.location).thenReturn(location);
- when(context.getElement(location)).thenReturn(element);
- int id = codec.encode(element);
- expect(codec.encode(element), id);
- expect(codec.decode(context, id), element);
- // check strings
- expect(stringCodec.nameToIndex, hasLength(2));
- expect(stringCodec.nameToIndex, containsPair('foo', 0));
- expect(stringCodec.nameToIndex, containsPair('bar', 1));
- }
-}
-
-
-@ReflectiveTestCase()
-class _RelationshipCodecTest {
- RelationshipCodec codec;
- StringCodec stringCodec = new StringCodec();
-
- void setUp() {
- codec = new RelationshipCodec(stringCodec);
- }
-
- void test_all() {
- Relationship relationship = Relationship.getRelationship('my-relationship');
- int id = codec.encode(relationship);
- expect(codec.decode(id), relationship);
- }
-}
-
-
-@ReflectiveTestCase()
-class _StringCodecTest {
- StringCodec codec = new StringCodec();
-
- void test_all() {
- int idA = codec.encode('aaa');
- int idB = codec.encode('bbb');
- expect(codec.decode(idA), 'aaa');
- expect(codec.decode(idB), 'bbb');
- }
-}

Powered by Google App Engine
This is Rietveld 408576698