| OLD | NEW |
| 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_services/index/index.dart'; | 7 import 'package:analysis_services/index/index.dart'; |
| 8 import 'package:analysis_services/src/index/store/codec.dart'; | 8 import 'package:analysis_services/src/index/store/codec.dart'; |
| 9 import 'package:analysis_testing/mocks.dart'; | 9 import 'package:analysis_testing/mocks.dart'; |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | 10 import 'package:analysis_testing/reflective_tests.dart'; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 { | 98 { |
| 99 int id = codec.encode(setter); | 99 int id = codec.encode(setter); |
| 100 expect(codec.decode(context, id), setter); | 100 expect(codec.decode(context, id), setter); |
| 101 } | 101 } |
| 102 { | 102 { |
| 103 int id = codec.encode(field); | 103 int id = codec.encode(field); |
| 104 expect(codec.decode(context, id), field); | 104 expect(codec.decode(context, id), field); |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 void test_encodeHash_notLocal() { |
| 109 resolveTestUnit(''' |
| 110 class A { |
| 111 void mainA() { |
| 112 int foo; // A |
| 113 } |
| 114 void mainB() { |
| 115 int foo; // B |
| 116 int bar; |
| 117 } |
| 118 } |
| 119 '''); |
| 120 MethodElement mainA = findElement('mainA'); |
| 121 MethodElement mainB = findElement('mainB'); |
| 122 Element fooA = mainA.localVariables[0]; |
| 123 Element fooB = mainB.localVariables[0]; |
| 124 Element bar = mainB.localVariables[1]; |
| 125 int id_fooA = codec.encodeHash(fooA); |
| 126 int id_fooB = codec.encodeHash(fooB); |
| 127 int id_bar = codec.encodeHash(bar); |
| 128 expect(id_fooA == id_fooB, isTrue); |
| 129 expect(id_fooA == id_bar, isFalse); |
| 130 } |
| 131 |
| 108 void test_localLocalVariable() { | 132 void test_localLocalVariable() { |
| 109 resolveTestUnit(''' | 133 resolveTestUnit(''' |
| 110 main() { | 134 main() { |
| 111 { | 135 { |
| 112 foo() { | 136 foo() { |
| 113 int bar; // A | 137 int bar; // A |
| 114 } | 138 } |
| 115 } | 139 } |
| 116 { | 140 { |
| 117 foo() { | 141 foo() { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 class _StringCodecTest { | 230 class _StringCodecTest { |
| 207 StringCodec codec = new StringCodec(); | 231 StringCodec codec = new StringCodec(); |
| 208 | 232 |
| 209 void test_all() { | 233 void test_all() { |
| 210 int idA = codec.encode('aaa'); | 234 int idA = codec.encode('aaa'); |
| 211 int idB = codec.encode('bbb'); | 235 int idB = codec.encode('bbb'); |
| 212 expect(codec.decode(idA), 'aaa'); | 236 expect(codec.decode(idA), 'aaa'); |
| 213 expect(codec.decode(idB), 'bbb'); | 237 expect(codec.decode(idB), 'bbb'); |
| 214 } | 238 } |
| 215 } | 239 } |
| OLD | NEW |