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

Side by Side Diff: pkg/analyzer/test/src/context/context_test.dart

Issue 1490233007: Remove the old task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@analyzer-breaking-0.27
Patch Set: Created 5 years 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) 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.src.context.context_test; 5 library test.src.context.context_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analyzer/file_system/memory_file_system.dart'; 9 import 'package:analyzer/file_system/memory_file_system.dart';
10 import 'package:analyzer/source/package_map_resolver.dart'; 10 import 'package:analyzer/source/package_map_resolver.dart';
11 import 'package:analyzer/src/cancelable_future.dart'; 11 import 'package:analyzer/src/cancelable_future.dart';
12 import 'package:analyzer/src/context/cache.dart'; 12 import 'package:analyzer/src/context/cache.dart';
13 import 'package:analyzer/src/context/context.dart'; 13 import 'package:analyzer/src/context/context.dart';
14 import 'package:analyzer/src/generated/ast.dart'; 14 import 'package:analyzer/src/generated/ast.dart';
15 import 'package:analyzer/src/generated/element.dart'; 15 import 'package:analyzer/src/generated/element.dart';
16 import 'package:analyzer/src/generated/engine.dart' 16 import 'package:analyzer/src/generated/engine.dart';
17 show
18 AnalysisContext,
19 AnalysisContextStatistics,
20 AnalysisDelta,
21 AnalysisEngine,
22 AnalysisErrorInfo,
23 AnalysisLevel,
24 AnalysisNotScheduledError,
25 AnalysisOptions,
26 AnalysisOptionsImpl,
27 AnalysisResult,
28 ApplyChangesStatus,
29 CacheState,
30 ChangeNotice,
31 ChangeSet,
32 IncrementalAnalysisCache,
33 TimestampedData;
34 import 'package:analyzer/src/generated/error.dart'; 17 import 'package:analyzer/src/generated/error.dart';
35 import 'package:analyzer/src/generated/java_engine.dart'; 18 import 'package:analyzer/src/generated/java_engine.dart';
36 import 'package:analyzer/src/generated/resolver.dart'; 19 import 'package:analyzer/src/generated/resolver.dart';
37 import 'package:analyzer/src/generated/scanner.dart'; 20 import 'package:analyzer/src/generated/scanner.dart';
38 import 'package:analyzer/src/generated/source.dart'; 21 import 'package:analyzer/src/generated/source.dart';
39 import 'package:analyzer/src/generated/utilities_collection.dart'; 22 import 'package:analyzer/src/generated/utilities_collection.dart';
40 import 'package:analyzer/src/task/dart.dart'; 23 import 'package:analyzer/src/task/dart.dart';
41 import 'package:analyzer/src/task/html.dart'; 24 import 'package:analyzer/src/task/html.dart';
42 import 'package:analyzer/task/dart.dart'; 25 import 'package:analyzer/task/dart.dart';
43 import 'package:analyzer/task/model.dart'; 26 import 'package:analyzer/task/model.dart';
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 expect(context.exists(null), isFalse); 830 expect(context.exists(null), isFalse);
848 } 831 }
849 832
850 void test_exists_overridden() { 833 void test_exists_overridden() {
851 Source source = new TestSource(); 834 Source source = new TestSource();
852 context.setContents(source, ""); 835 context.setContents(source, "");
853 expect(context.exists(source), isTrue); 836 expect(context.exists(source), isTrue);
854 } 837 }
855 838
856 void test_exists_true() { 839 void test_exists_true() {
857 expect(context.exists(new AnalysisContextImplTest_Source_exists_true()), 840 expect(context.exists(new _AnalysisContextImplTest_Source_exists_true()),
858 isTrue); 841 isTrue);
859 } 842 }
860 843
861 void test_getAnalysisOptions() { 844 void test_getAnalysisOptions() {
862 expect(context.analysisOptions, isNotNull); 845 expect(context.analysisOptions, isNotNull);
863 } 846 }
864 847
865 void test_getContents_fromSource() { 848 void test_getContents_fromSource() {
866 String content = "library lib;"; 849 String content = "library lib;";
867 TimestampedData<String> contents = 850 TimestampedData<String> contents =
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 expect(info, isNull); 1290 expect(info, isNull);
1308 context.parseCompilationUnit(source); 1291 context.parseCompilationUnit(source);
1309 info = context.getLineInfo(source); 1292 info = context.getLineInfo(source);
1310 expect(info, isNotNull); 1293 expect(info, isNotNull);
1311 } 1294 }
1312 1295
1313 void test_getModificationStamp_fromSource() { 1296 void test_getModificationStamp_fromSource() {
1314 int stamp = 42; 1297 int stamp = 42;
1315 expect( 1298 expect(
1316 context.getModificationStamp( 1299 context.getModificationStamp(
1317 new AnalysisContextImplTest_Source_getModificationStamp_fromSource( 1300 new _AnalysisContextImplTest_Source_getModificationStamp_fromSource(
1318 stamp)), 1301 stamp)),
1319 stamp); 1302 stamp);
1320 } 1303 }
1321 1304
1322 void test_getModificationStamp_overridden() { 1305 void test_getModificationStamp_overridden() {
1323 int stamp = 42; 1306 int stamp = 42;
1324 Source source = 1307 Source source =
1325 new AnalysisContextImplTest_Source_getModificationStamp_overridden( 1308 new _AnalysisContextImplTest_Source_getModificationStamp_overridden(
1326 stamp); 1309 stamp);
1327 context.setContents(source, ""); 1310 context.setContents(source, "");
1328 expect(stamp != context.getModificationStamp(source), isTrue); 1311 expect(stamp != context.getModificationStamp(source), isTrue);
1329 } 1312 }
1330 1313
1331 void test_getPublicNamespace_element() { 1314 void test_getPublicNamespace_element() {
1332 Source source = addSource("/test.dart", "class A {}"); 1315 Source source = addSource("/test.dart", "class A {}");
1333 LibraryElement library = context.computeLibraryElement(source); 1316 LibraryElement library = context.computeLibraryElement(source);
1334 expect(library, isNotNull); 1317 expect(library, isNotNull);
1335 Namespace namespace = context.getPublicNamespace(library); 1318 Namespace namespace = context.getPublicNamespace(library);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 1358
1376 TestSourceWithUri source2 = 1359 TestSourceWithUri source2 =
1377 new TestSourceWithUri(filePath, Uri.parse('package:foo/file.dart')); 1360 new TestSourceWithUri(filePath, Uri.parse('package:foo/file.dart'));
1378 expected.add(source2); 1361 expected.add(source2);
1379 changeSet.addedSource(source2); 1362 changeSet.addedSource(source2);
1380 1363
1381 context.applyChanges(changeSet); 1364 context.applyChanges(changeSet);
1382 expect(context.getSourcesWithFullName(filePath), unorderedEquals(expected)); 1365 expect(context.getSourcesWithFullName(filePath), unorderedEquals(expected));
1383 } 1366 }
1384 1367
1385 void test_getStatistics() {
1386 AnalysisContextStatistics statistics = context.statistics;
1387 expect(statistics, isNotNull);
1388 // The following lines are fragile.
1389 // The values depend on the number of libraries in the SDK.
1390 // assertLength(0, statistics.getCacheRows());
1391 // assertLength(0, statistics.getExceptions());
1392 // assertLength(0, statistics.getSources());
1393 }
1394
1395 void test_handleContentsChanged() { 1368 void test_handleContentsChanged() {
1396 ContentCache contentCache = new ContentCache(); 1369 ContentCache contentCache = new ContentCache();
1397 context.contentCache = contentCache; 1370 context.contentCache = contentCache;
1398 String oldContents = 'foo() {}'; 1371 String oldContents = 'foo() {}';
1399 String newContents = 'bar() {}'; 1372 String newContents = 'bar() {}';
1400 // old contents 1373 // old contents
1401 Source source = addSource("/test.dart", oldContents); 1374 Source source = addSource("/test.dart", oldContents);
1402 _analyzeAll_assertFinished(); 1375 _analyzeAll_assertFinished();
1403 expect(context.getResolvedCompilationUnit2(source, source), isNotNull); 1376 expect(context.getResolvedCompilationUnit2(source, source), isNotNull);
1404 // new contents 1377 // new contents
(...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after
2720 2693
2721 void _performPendingAnalysisTasks([int maxTasks = 512]) { 2694 void _performPendingAnalysisTasks([int maxTasks = 512]) {
2722 for (int i = 0; context.performAnalysisTask().hasMoreWork; i++) { 2695 for (int i = 0; context.performAnalysisTask().hasMoreWork; i++) {
2723 if (i > maxTasks) { 2696 if (i > maxTasks) {
2724 fail('Analysis did not terminate.'); 2697 fail('Analysis did not terminate.');
2725 } 2698 }
2726 } 2699 }
2727 } 2700 }
2728 } 2701 }
2729 2702
2703 class _AnalysisContextImplTest_Source_exists_true extends TestSource {
2704 @override
2705 bool exists() => true;
2706 }
2707
2708 class _AnalysisContextImplTest_Source_getModificationStamp_fromSource
2709 extends TestSource {
2710 int stamp;
2711 _AnalysisContextImplTest_Source_getModificationStamp_fromSource(this.stamp);
2712 @override
2713 int get modificationStamp => stamp;
2714 }
2715
2716 class _AnalysisContextImplTest_Source_getModificationStamp_overridden
2717 extends TestSource {
2718 int stamp;
2719 _AnalysisContextImplTest_Source_getModificationStamp_overridden(this.stamp);
2720 @override
2721 int get modificationStamp => stamp;
2722 }
2723
2730 class _AnalysisContextImplTest_test_applyChanges_removeContainer 2724 class _AnalysisContextImplTest_test_applyChanges_removeContainer
2731 implements SourceContainer { 2725 implements SourceContainer {
2732 Source libB; 2726 Source libB;
2733 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); 2727 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB);
2734 @override 2728 @override
2735 bool contains(Source source) => source == libB; 2729 bool contains(Source source) => source == libB;
2736 } 2730 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/context/cache_test.dart ('k') | pkg/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698