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.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/src/cancelable_future.dart'; | 9 import 'package:analyzer/src/cancelable_future.dart'; |
10 import 'package:analyzer/src/context/cache.dart'; | 10 import 'package:analyzer/src/context/cache.dart'; |
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 837 } |
838 | 838 |
839 void fail_resolveHtmlUnit() { | 839 void fail_resolveHtmlUnit() { |
840 Source source = addSource("/lib.html", "<html></html>"); | 840 Source source = addSource("/lib.html", "<html></html>"); |
841 ht.HtmlUnit unit = context.resolveHtmlUnit(source); | 841 ht.HtmlUnit unit = context.resolveHtmlUnit(source); |
842 expect(unit, isNotNull); | 842 expect(unit, isNotNull); |
843 } | 843 } |
844 | 844 |
845 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 845 void fail_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
846 AnalysisOptionsImpl options = | 846 AnalysisOptionsImpl options = |
847 new AnalysisOptionsImpl.con1(context.analysisOptions); | 847 new AnalysisOptionsImpl.from(context.analysisOptions); |
848 List<Source> sources = new List<Source>(); | 848 List<Source> sources = new List<Source>(); |
849 for (int index = 0; index < options.cacheSize; index++) { | 849 for (int index = 0; index < options.cacheSize; index++) { |
850 sources.add(addSource("/lib.dart$index", "")); | 850 sources.add(addSource("/lib.dart$index", "")); |
851 } | 851 } |
852 context.analysisPriorityOrder = sources; | 852 context.analysisPriorityOrder = sources; |
853 int oldPriorityOrderSize = _getPriorityOrder(context).length; | 853 int oldPriorityOrderSize = _getPriorityOrder(context).length; |
854 options.cacheSize = options.cacheSize - 10; | 854 options.cacheSize = options.cacheSize - 10; |
855 context.analysisOptions = options; | 855 context.analysisOptions = options; |
856 expect(oldPriorityOrderSize > _getPriorityOrder(context).length, isTrue); | 856 expect(oldPriorityOrderSize > _getPriorityOrder(context).length, isTrue); |
857 } | 857 } |
(...skipping 862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1720 } | 1720 } |
1721 | 1721 |
1722 void test_setAnalysisPriorityOrder_nonEmpty() { | 1722 void test_setAnalysisPriorityOrder_nonEmpty() { |
1723 List<Source> sources = new List<Source>(); | 1723 List<Source> sources = new List<Source>(); |
1724 sources.add(addSource("/lib.dart", "library lib;")); | 1724 sources.add(addSource("/lib.dart", "library lib;")); |
1725 context.analysisPriorityOrder = sources; | 1725 context.analysisPriorityOrder = sources; |
1726 } | 1726 } |
1727 | 1727 |
1728 void test_setChangedContents_notResolved() { | 1728 void test_setChangedContents_notResolved() { |
1729 AnalysisOptionsImpl options = | 1729 AnalysisOptionsImpl options = |
1730 new AnalysisOptionsImpl.con1(context.analysisOptions); | 1730 new AnalysisOptionsImpl.from(context.analysisOptions); |
1731 options.incremental = true; | 1731 options.incremental = true; |
1732 context.analysisOptions = options; | 1732 context.analysisOptions = options; |
1733 String oldCode = r''' | 1733 String oldCode = r''' |
1734 library lib; | 1734 library lib; |
1735 int a = 0;'''; | 1735 int a = 0;'''; |
1736 Source librarySource = addSource("/lib.dart", oldCode); | 1736 Source librarySource = addSource("/lib.dart", oldCode); |
1737 int offset = oldCode.indexOf("int a") + 4; | 1737 int offset = oldCode.indexOf("int a") + 4; |
1738 String newCode = r''' | 1738 String newCode = r''' |
1739 library lib; | 1739 library lib; |
1740 int ya = 0;'''; | 1740 int ya = 0;'''; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1855 expect(context.pendingFutureSources_forTesting, isEmpty); | 1855 expect(context.pendingFutureSources_forTesting, isEmpty); |
1856 return pumpEventQueue().then((_) { | 1856 return pumpEventQueue().then((_) { |
1857 expect(completed, isTrue); | 1857 expect(completed, isTrue); |
1858 expect(context.pendingFutureSources_forTesting, isEmpty); | 1858 expect(context.pendingFutureSources_forTesting, isEmpty); |
1859 }); | 1859 }); |
1860 } | 1860 } |
1861 | 1861 |
1862 void xtest_performAnalysisTask_stress() { | 1862 void xtest_performAnalysisTask_stress() { |
1863 int maxCacheSize = 4; | 1863 int maxCacheSize = 4; |
1864 AnalysisOptionsImpl options = | 1864 AnalysisOptionsImpl options = |
1865 new AnalysisOptionsImpl.con1(context.analysisOptions); | 1865 new AnalysisOptionsImpl.from(context.analysisOptions); |
1866 options.cacheSize = maxCacheSize; | 1866 options.cacheSize = maxCacheSize; |
1867 context.analysisOptions = options; | 1867 context.analysisOptions = options; |
1868 int sourceCount = maxCacheSize + 2; | 1868 int sourceCount = maxCacheSize + 2; |
1869 List<Source> sources = new List<Source>(); | 1869 List<Source> sources = new List<Source>(); |
1870 ChangeSet changeSet = new ChangeSet(); | 1870 ChangeSet changeSet = new ChangeSet(); |
1871 for (int i = 0; i < sourceCount; i++) { | 1871 for (int i = 0; i < sourceCount; i++) { |
1872 Source source = addSource("/lib$i.dart", "library lib$i;"); | 1872 Source source = addSource("/lib$i.dart", "library lib$i;"); |
1873 sources.add(source); | 1873 sources.add(source); |
1874 changeSet.addedSource(source); | 1874 changeSet.addedSource(source); |
1875 } | 1875 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2034 : super(name, UriKind.FILE_URI); | 2034 : super(name, UriKind.FILE_URI); |
2035 | 2035 |
2036 @override | 2036 @override |
2037 TimestampedData<String> get contents { | 2037 TimestampedData<String> get contents { |
2038 throw 'Read error'; | 2038 throw 'Read error'; |
2039 } | 2039 } |
2040 | 2040 |
2041 @override | 2041 @override |
2042 bool exists() => true; | 2042 bool exists() => true; |
2043 } | 2043 } |
OLD | NEW |