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

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

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
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/src/cancelable_future.dart'; 10 import 'package:analyzer/src/cancelable_future.dart';
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 completed = true; 642 completed = true;
643 }); 643 });
644 return pumpEventQueue().then((_) { 644 return pumpEventQueue().then((_) {
645 expect(completed, isFalse); 645 expect(completed, isFalse);
646 _performPendingAnalysisTasks(); 646 _performPendingAnalysisTasks();
647 }).then((_) => pumpEventQueue()).then((_) { 647 }).then((_) => pumpEventQueue()).then((_) {
648 expect(completed, isTrue); 648 expect(completed, isTrue);
649 }); 649 });
650 } 650 }
651 651
652 void test_configurationData() {
653 var key = new ResultDescriptor('test_key', '');
654 var testData = ['test', 'data'];
655 context.setConfigurationData(key, testData);
656 expect(context.getConfigurationData(key), testData);
657 var unusedKey = new ResultDescriptor('unused_key', '');
658 expect(context.getConfigurationData(unusedKey), null);
659 }
660
652 void test_dispose() { 661 void test_dispose() {
653 expect(context.isDisposed, isFalse); 662 expect(context.isDisposed, isFalse);
654 context.dispose(); 663 context.dispose();
655 expect(context.isDisposed, isTrue); 664 expect(context.isDisposed, isTrue);
656 } 665 }
657 666
658 void test_ensureResolvedDartUnits_definingUnit_hasResolved() { 667 void test_ensureResolvedDartUnits_definingUnit_hasResolved() {
659 Source source = addSource('/test.dart', ''); 668 Source source = addSource('/test.dart', '');
660 LibrarySpecificUnit libTarget = new LibrarySpecificUnit(source, source); 669 LibrarySpecificUnit libTarget = new LibrarySpecificUnit(source, source);
661 analysisDriver.computeResult(libTarget, RESOLVED_UNIT); 670 analysisDriver.computeResult(libTarget, RESOLVED_UNIT);
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 "/test.html", 907 "/test.html",
899 r''' 908 r'''
900 <html><head> 909 <html><head>
901 <script type='application/dart' src='test.dart'/> 910 <script type='application/dart' src='test.dart'/>
902 </head></html>'''); 911 </head></html>''');
903 AnalysisErrorInfo errorInfo = context.getErrors(source); 912 AnalysisErrorInfo errorInfo = context.getErrors(source);
904 expect(errorInfo, isNotNull); 913 expect(errorInfo, isNotNull);
905 List<AnalysisError> errors = errorInfo.errors; 914 List<AnalysisError> errors = errorInfo.errors;
906 expect(errors, hasLength(0)); 915 expect(errors, hasLength(0));
907 errors = context.computeErrors(source); 916 errors = context.computeErrors(source);
908 expect(errors, hasLength(3)); 917 expect(errors, hasLength(2));
909 } 918 }
910 919
911 void test_getHtmlFilesReferencing_html() { 920 void test_getHtmlFilesReferencing_html() {
912 Source htmlSource = addSource( 921 Source htmlSource = addSource(
913 "/test.html", 922 "/test.html",
914 r''' 923 r'''
915 <html><head> 924 <html><head>
916 <script type='application/dart' src='test.dart'/> 925 <script type='application/dart' src='test.dart'/>
917 <script type='application/dart' src='test.js'/> 926 <script type='application/dart' src='test.js'/>
918 </head></html>'''); 927 </head></html>''');
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1184 sources = context.librarySources; 1193 sources = context.librarySources;
1185 expect(sources, hasLength(originalLength + 1)); 1194 expect(sources, hasLength(originalLength + 1));
1186 for (Source returnedSource in sources) { 1195 for (Source returnedSource in sources) {
1187 if (returnedSource == source) { 1196 if (returnedSource == source) {
1188 return; 1197 return;
1189 } 1198 }
1190 } 1199 }
1191 fail("The added source was not in the list of library sources"); 1200 fail("The added source was not in the list of library sources");
1192 } 1201 }
1193 1202
1203 void test_getLibrarySources_inSDK() {
1204 Source source = addSource(
1205 '/test.dart',
1206 r'''
1207 import 'dart:async';
1208 Stream S = null;
1209 ''');
1210 LibraryElement testLibrary = context.computeLibraryElement(source);
1211 // prepare "Stream" ClassElement
1212 ClassElement streamElement;
1213 {
1214 CompilationUnitElement testUnit = testLibrary.definingCompilationUnit;
1215 InterfaceType streamType = testUnit.topLevelVariables[0].type;
1216 streamElement = streamType.element;
1217 }
1218 // must be from SDK context
1219 AnalysisContext sdkContext = context.sourceFactory.dartSdk.context;
1220 expect(sdkContext, streamElement.context);
1221 Source intSource = streamElement.source;
1222 // must be in the "async" library - SDK context
1223 {
1224 List<Source> coreLibraries = sdkContext.getLibrariesContaining(intSource);
1225 expect(coreLibraries, hasLength(1));
1226 Source coreSource = coreLibraries[0];
1227 expect(coreSource.isInSystemLibrary, isTrue);
1228 expect(coreSource.shortName, 'async.dart');
1229 }
1230 // must be in the "async" library - main context
1231 {
1232 List<Source> coreLibraries = context.getLibrariesContaining(intSource);
1233 expect(coreLibraries, hasLength(1));
1234 Source coreSource = coreLibraries[0];
1235 expect(coreSource.isInSystemLibrary, isTrue);
1236 expect(coreSource.shortName, 'async.dart');
1237 }
1238 }
1239
1194 void test_getLineInfo() { 1240 void test_getLineInfo() {
1195 Source source = addSource( 1241 Source source = addSource(
1196 "/test.dart", 1242 "/test.dart",
1197 r''' 1243 r'''
1198 library lib; 1244 library lib;
1199 1245
1200 main() {}'''); 1246 main() {}''');
1201 LineInfo info = context.getLineInfo(source); 1247 LineInfo info = context.getLineInfo(source);
1202 expect(info, isNull); 1248 expect(info, isNull);
1203 context.parseCompilationUnit(source); 1249 context.parseCompilationUnit(source);
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
1711 void test_performAnalysisTask_importedLibraryAdd_html() { 1757 void test_performAnalysisTask_importedLibraryAdd_html() {
1712 Source htmlSource = addSource( 1758 Source htmlSource = addSource(
1713 "/page.html", 1759 "/page.html",
1714 r''' 1760 r'''
1715 <html><body><script type="application/dart"> 1761 <html><body><script type="application/dart">
1716 import '/libB.dart'; 1762 import '/libB.dart';
1717 main() {print('hello dart');} 1763 main() {print('hello dart');}
1718 </script></body></html>'''); 1764 </script></body></html>''');
1719 _analyzeAll_assertFinished(); 1765 _analyzeAll_assertFinished();
1720 context.computeErrors(htmlSource); 1766 context.computeErrors(htmlSource);
1721 expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)), 1767 // expect(_hasAnalysisErrorWithErrorSeverity(context.getErrors(htmlSource)),
1722 isTrue, 1768 // isTrue,
1723 reason: "htmlSource has an error"); 1769 // reason: "htmlSource has an error");
1724 // add libB.dart and analyze 1770 // add libB.dart and analyze
1725 Source libBSource = addSource("/libB.dart", "library libB;"); 1771 Source libBSource = addSource("/libB.dart", "library libB;");
1726 _analyzeAll_assertFinished(); 1772 _analyzeAll_assertFinished();
1727 expect( 1773 expect(
1728 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull, 1774 context.getResolvedCompilationUnit2(libBSource, libBSource), isNotNull,
1729 reason: "libB resolved 2"); 1775 reason: "libB resolved 2");
1730 // TODO (danrubel) commented out to fix red bots 1776 // TODO (danrubel) commented out to fix red bots
1731 // context.computeErrors(htmlSource); 1777 // context.computeErrors(htmlSource);
1732 // AnalysisErrorInfo errors = _context.getErrors(htmlSource); 1778 // AnalysisErrorInfo errors = _context.getErrors(htmlSource);
1733 // expect( 1779 // expect(
(...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after
2515 } 2561 }
2516 } 2562 }
2517 2563
2518 class _AnalysisContextImplTest_test_applyChanges_removeContainer 2564 class _AnalysisContextImplTest_test_applyChanges_removeContainer
2519 implements SourceContainer { 2565 implements SourceContainer {
2520 Source libB; 2566 Source libB;
2521 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB); 2567 _AnalysisContextImplTest_test_applyChanges_removeContainer(this.libB);
2522 @override 2568 @override
2523 bool contains(Source source) => source == libB; 2569 bool contains(Source source) => source == libB;
2524 } 2570 }
OLDNEW
« no previous file with comments | « packages/analyzer/test/generated/parser_test.dart ('k') | packages/analyzer/test/src/context/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698