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

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

Issue 877693004: Fix for file:// package: references to the same element. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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.store.codec; 5 library test.services.src.index.store.codec;
6 6
7 import 'package:analysis_server/src/services/index/index.dart'; 7 import 'package:analysis_server/src/services/index/index.dart';
8 import 'package:analysis_server/src/services/index/store/codec.dart'; 8 import 'package:analysis_server/src/services/index/store/codec.dart';
9 import 'package:analyzer/src/generated/element.dart'; 9 import 'package:analyzer/src/generated/element.dart';
10 import 'package:analyzer/src/generated/engine.dart'; 10 import 'package:analyzer/src/generated/engine.dart';
11 import 'package:analyzer/src/generated/source.dart';
11 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
12 13
13 import '../../../abstract_single_unit.dart'; 14 import '../../../abstract_single_unit.dart';
14 import '../../../mocks.dart'; 15 import '../../../mocks.dart';
15 import '../../../reflective_tests.dart'; 16 import '../../../reflective_tests.dart';
16 17
17 18
18 main() { 19 main() {
19 groupSep = ' | '; 20 groupSep = ' | ';
20 runReflectiveTests(_ContextCodecTest); 21 runReflectiveTests(_ContextCodecTest);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 { 115 {
115 int id = codec.encode(setter, false); 116 int id = codec.encode(setter, false);
116 expect(codec.decode(context, id), setter); 117 expect(codec.decode(context, id), setter);
117 } 118 }
118 { 119 {
119 int id = codec.encode(field, false); 120 int id = codec.encode(field, false);
120 expect(codec.decode(context, id), field); 121 expect(codec.decode(context, id), field);
121 } 122 }
122 } 123 }
123 124
125 void test_filePackage_uriMix() {
126 MethodElement buildMethodElement(Source source) {
127 CompilationUnitElementImpl unitElement = new CompilationUnitElementImpl('f ile.dart');
128 LibraryElementImpl libraryElement = new LibraryElementImpl(null, 'lib', 0) ;
129 ClassElementImpl classElement = new ClassElementImpl('A', 0);
130 MethodElementImpl methodElement = new MethodElementImpl('m', 0);
131 unitElement.source = source;
132 libraryElement.definingCompilationUnit = unitElement;
133 unitElement.types = [classElement];
134 classElement.methods = [methodElement];
135 return methodElement;
136 }
137 // file:
138 int fileId;
139 {
140 Source source = new _TestSource('/my/file.dart', 'file:///my/file.dart');
141 var methodElement = buildMethodElement(source);
142 fileId = codec.encode(methodElement, true);
143 }
144 // package:
145 int packageId;
146 {
147 Source source = new _TestSource('/my/file.dart', 'package:my_pkg/file.dart ');
148 var methodElement = buildMethodElement(source);
149 packageId = codec.encode(methodElement, true);
150 }
151 // should be the same
152 expect(packageId, fileId);
153 }
154
124 void test_localLocalVariable() { 155 void test_localLocalVariable() {
125 resolveTestUnit(''' 156 resolveTestUnit('''
126 main() { 157 main() {
127 { 158 {
128 foo() { 159 foo() {
129 int bar; // A 160 int bar; // A
130 } 161 }
131 } 162 }
132 { 163 {
133 foo() { 164 foo() {
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 class _StringCodecTest { 253 class _StringCodecTest {
223 StringCodec codec = new StringCodec(); 254 StringCodec codec = new StringCodec();
224 255
225 void test_all() { 256 void test_all() {
226 int idA = codec.encode('aaa'); 257 int idA = codec.encode('aaa');
227 int idB = codec.encode('bbb'); 258 int idB = codec.encode('bbb');
228 expect(codec.decode(idA), 'aaa'); 259 expect(codec.decode(idA), 'aaa');
229 expect(codec.decode(idB), 'bbb'); 260 expect(codec.decode(idB), 'bbb');
230 } 261 }
231 } 262 }
263
264
265 class _TestSource implements Source {
266 String fullName;
267 String encoding;
268
269 _TestSource(this.fullName, this.encoding);
270
271 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
272 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698