| 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 // This code was auto-generated, is not intended to be edited, and is subject to | 5 // This code was auto-generated, is not intended to be edited, and is subject to |
| 6 // significant change. Please see the README file for more information. | 6 // significant change. Please see the README file for more information. |
| 7 | 7 |
| 8 library engine.engine_test; | 8 library engine.engine_test; |
| 9 | 9 |
| 10 import 'dart:async'; | 10 import 'dart:async'; |
| 11 import 'dart:collection'; | 11 import 'dart:collection'; |
| 12 | 12 |
| 13 import 'package:analyzer/src/cancelable_future.dart'; | 13 import 'package:analyzer/src/cancelable_future.dart'; |
| 14 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 15 import 'package:analyzer/src/generated/constant.dart'; | 15 import 'package:analyzer/src/generated/constant.dart'; |
| 16 import 'package:analyzer/src/generated/element.dart'; | 16 import 'package:analyzer/src/generated/element.dart'; |
| 17 import 'package:analyzer/src/generated/engine.dart'; | 17 import 'package:analyzer/src/generated/engine.dart'; |
| 18 import 'package:analyzer/src/generated/error.dart'; | 18 import 'package:analyzer/src/generated/error.dart'; |
| 19 import 'package:analyzer/src/generated/html.dart' as ht; | 19 import 'package:analyzer/src/generated/html.dart' as ht; |
| 20 import 'package:analyzer/src/generated/java_core.dart'; | 20 import 'package:analyzer/src/generated/java_core.dart'; |
| 21 import 'package:analyzer/src/generated/java_engine.dart'; | 21 import 'package:analyzer/src/generated/java_engine.dart'; |
| 22 import 'package:analyzer/src/generated/java_engine_io.dart'; | 22 import 'package:analyzer/src/generated/java_engine_io.dart'; |
| 23 import 'package:analyzer/src/generated/java_io.dart'; |
| 23 import 'package:analyzer/src/generated/parser.dart'; | 24 import 'package:analyzer/src/generated/parser.dart'; |
| 24 import 'package:analyzer/src/generated/resolver.dart'; | 25 import 'package:analyzer/src/generated/resolver.dart'; |
| 25 import 'package:analyzer/src/generated/scanner.dart'; | 26 import 'package:analyzer/src/generated/scanner.dart'; |
| 26 import 'package:analyzer/src/generated/sdk.dart'; | 27 import 'package:analyzer/src/generated/sdk.dart'; |
| 27 import 'package:analyzer/src/generated/sdk_io.dart'; | 28 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 28 import 'package:analyzer/src/generated/source_io.dart'; | 29 import 'package:analyzer/src/generated/source_io.dart'; |
| 29 import 'package:analyzer/src/generated/testing/ast_factory.dart'; | 30 import 'package:analyzer/src/generated/testing/ast_factory.dart'; |
| 30 import 'package:analyzer/src/generated/testing/element_factory.dart'; | 31 import 'package:analyzer/src/generated/testing/element_factory.dart'; |
| 31 import 'package:analyzer/src/generated/utilities_collection.dart'; | 32 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 32 import 'package:analyzer/src/services/lint.dart'; | 33 import 'package:analyzer/src/services/lint.dart'; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 TestSource source = new TestSource(); | 91 TestSource source = new TestSource(); |
| 91 DartEntry entry = new DartEntry(); | 92 DartEntry entry = new DartEntry(); |
| 92 cache.put(source, entry); | 93 cache.put(source, entry); |
| 93 MapIterator<Source, SourceEntry> iterator = cache.iterator(); | 94 MapIterator<Source, SourceEntry> iterator = cache.iterator(); |
| 94 expect(iterator.moveNext(), isTrue); | 95 expect(iterator.moveNext(), isTrue); |
| 95 expect(iterator.key, same(source)); | 96 expect(iterator.key, same(source)); |
| 96 expect(iterator.value, same(entry)); | 97 expect(iterator.value, same(entry)); |
| 97 expect(iterator.moveNext(), isFalse); | 98 expect(iterator.moveNext(), isFalse); |
| 98 } | 99 } |
| 99 | 100 |
| 101 /** |
| 102 * Verify that if multiple Source objects refer to the same file via |
| 103 * different URIs, they are treated as separate entries in the cache. |
| 104 */ |
| 105 void test_lookup_distinguishes_uris() { |
| 106 CachePartition partition = |
| 107 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 109 JavaFile file = new JavaFile('baz.dart'); |
| 110 Source source1 = new FileBasedSource.con1(file); |
| 111 Source source2 = |
| 112 new FileBasedSource.con2(Uri.parse('package:foo/baz.dart'), file); |
| 113 Source source3 = |
| 114 new FileBasedSource.con2(Uri.parse('package:bar/baz.dart'), file); |
| 115 DartEntry entry1 = new DartEntry(); |
| 116 DartEntry entry2 = new DartEntry(); |
| 117 DartEntry entry3 = new DartEntry(); |
| 118 cache.put(source1, entry1); |
| 119 cache.put(source2, entry2); |
| 120 cache.put(source3, entry3); |
| 121 expect(cache.get(source1), same(entry1)); |
| 122 expect(cache.get(source2), same(entry2)); |
| 123 expect(cache.get(source3), same(entry3)); |
| 124 } |
| 125 |
| 100 void test_put_noFlush() { | 126 void test_put_noFlush() { |
| 101 CachePartition partition = | 127 CachePartition partition = |
| 102 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 128 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 103 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 129 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 104 TestSource source = new TestSource(); | 130 TestSource source = new TestSource(); |
| 105 DartEntry entry = new DartEntry(); | 131 DartEntry entry = new DartEntry(); |
| 106 cache.put(source, entry); | 132 cache.put(source, entry); |
| 107 expect(cache.get(source), same(entry)); | 133 expect(cache.get(source), same(entry)); |
| 108 } | 134 } |
| 109 | 135 |
| (...skipping 7050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7160 bool exists() => true; | 7186 bool exists() => true; |
| 7161 } | 7187 } |
| 7162 | 7188 |
| 7163 | 7189 |
| 7164 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 7190 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 7165 CacheRetentionPolicy { | 7191 CacheRetentionPolicy { |
| 7166 @override | 7192 @override |
| 7167 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 7193 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7168 RetentionPriority.LOW; | 7194 RetentionPriority.LOW; |
| 7169 } | 7195 } |
| OLD | NEW |