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

Side by Side Diff: pkg/analyzer/test/src/summary/incremental_cache_test.dart

Issue 2060433003: Optimize paths comparision in source closure sorting. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/element/element.dart'; 5 import 'package:analyzer/dart/element/element.dart';
6 import 'package:analyzer/src/generated/error.dart'; 6 import 'package:analyzer/src/generated/error.dart';
7 import 'package:analyzer/src/generated/source.dart'; 7 import 'package:analyzer/src/generated/source.dart';
8 import 'package:analyzer/src/summary/incremental_cache.dart'; 8 import 'package:analyzer/src/summary/incremental_cache.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
11 import '../../generated/test_support.dart'; 11 import '../../generated/test_support.dart';
12 import '../../reflective_tests.dart'; 12 import '../../reflective_tests.dart';
13 import '../abstract_single_unit.dart'; 13 import '../abstract_single_unit.dart';
14 14
15 main() { 15 main() {
16 groupSep = ' | '; 16 groupSep = ' | ';
17 runReflectiveTests(ComparePathsTest);
17 runReflectiveTests(IncrementalCacheTest); 18 runReflectiveTests(IncrementalCacheTest);
18 } 19 }
19 20
21 @reflectiveTest
22 class ComparePathsTest extends AbstractSingleUnitTest {
23 void test_empty() {
24 expect(comparePaths('', ''), 0);
25 }
26
27 void test_equal() {
28 expect(comparePaths('abc', 'abc'), 0);
29 }
30
31 void test_longer_suffixAfter() {
32 expect(comparePaths('aab', 'aa'), 1);
33 }
34
35 void test_longer_suffixBefore() {
36 expect(comparePaths('aaa', 'ab'), -1);
37 }
38
39 void test_longer_suffixSame() {
40 expect(comparePaths('aaa', 'aa'), 1);
41 }
42
43 void test_sameLength_before0() {
44 expect(comparePaths('aaa', 'bbb'), -1);
45 }
46
47 void test_sameLength_before1() {
48 expect(comparePaths('aaa', 'bba'), -1);
49 }
50
51 void test_sameLength_before2() {
52 expect(comparePaths('aaa', 'bba'), -1);
53 }
54
55 void test_shorter_suffixAfter() {
56 expect(comparePaths('ab', 'aaa'), 1);
57 }
58
59 void test_shorter_suffixBefore() {
60 expect(comparePaths('aa', 'aab'), -1);
61 }
62
63 void test_shorter_suffixSame() {
64 expect(comparePaths('aa', 'aaa'), -1);
65 }
66 }
67
20 /** 68 /**
21 * TODO(scheglov) write more tests for invalidation. 69 * TODO(scheglov) write more tests for invalidation.
22 */ 70 */
23 @reflectiveTest 71 @reflectiveTest
24 class IncrementalCacheTest extends AbstractSingleUnitTest { 72 class IncrementalCacheTest extends AbstractSingleUnitTest {
25 _TestCacheStorage storage = new _TestCacheStorage(); 73 _TestCacheStorage storage = new _TestCacheStorage();
26 IncrementalCache cache; 74 IncrementalCache cache;
27 75
28 Source putLibrary(String path, String code) { 76 Source putLibrary(String path, String code) {
29 Source source = addSource(path, code); 77 Source source = addSource(path, code);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 @override 285 @override
238 List<int> get(String key) { 286 List<int> get(String key) {
239 return map[key]; 287 return map[key];
240 } 288 }
241 289
242 @override 290 @override
243 void put(String key, List<int> bytes) { 291 void put(String key, List<int> bytes) {
244 map[key] = bytes; 292 map[key] = bytes;
245 } 293 }
246 } 294 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698