| 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:collection'; | 10 import 'dart:collection'; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 101 } |
| 102 | 102 |
| 103 void test_setMaxCacheSize() { | 103 void test_setMaxCacheSize() { |
| 104 CachePartition partition = new UniversalCachePartition( | 104 CachePartition partition = new UniversalCachePartition( |
| 105 null, | 105 null, |
| 106 8, | 106 8, |
| 107 new _AnalysisCacheTest_test_setMaxCacheSize()); | 107 new _AnalysisCacheTest_test_setMaxCacheSize()); |
| 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 108 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 109 int size = 6; | 109 int size = 6; |
| 110 for (int i = 0; i < size; i++) { | 110 for (int i = 0; i < size; i++) { |
| 111 Source source = new TestSource("/test${i}.dart"); | 111 Source source = new TestSource("/test$i.dart"); |
| 112 DartEntry entry = new DartEntry(); | 112 DartEntry entry = new DartEntry(); |
| 113 entry.setValue(DartEntry.PARSED_UNIT, null); | 113 entry.setValue(DartEntry.PARSED_UNIT, null); |
| 114 cache.put(source, entry); | 114 cache.put(source, entry); |
| 115 cache.accessedAst(source); | 115 cache.accessedAst(source); |
| 116 } | 116 } |
| 117 _assertNonFlushedCount(size, cache); | 117 _assertNonFlushedCount(size, cache); |
| 118 int newSize = size - 2; | 118 int newSize = size - 2; |
| 119 partition.maxCacheSize = newSize; | 119 partition.maxCacheSize = newSize; |
| 120 _assertNonFlushedCount(newSize, cache); | 120 _assertNonFlushedCount(newSize, cache); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void test_size() { | 123 void test_size() { |
| 124 CachePartition partition = | 124 CachePartition partition = |
| 125 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); | 125 new UniversalCachePartition(null, 8, new DefaultRetentionPolicy()); |
| 126 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); | 126 AnalysisCache cache = new AnalysisCache(<CachePartition>[partition]); |
| 127 int size = 4; | 127 int size = 4; |
| 128 for (int i = 0; i < size; i++) { | 128 for (int i = 0; i < size; i++) { |
| 129 Source source = new TestSource("/test${i}.dart"); | 129 Source source = new TestSource("/test$i.dart"); |
| 130 cache.put(source, new DartEntry()); | 130 cache.put(source, new DartEntry()); |
| 131 cache.accessedAst(source); | 131 cache.accessedAst(source); |
| 132 } | 132 } |
| 133 JUnitTestCase.assertEquals(size, cache.size()); | 133 JUnitTestCase.assertEquals(size, cache.size()); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void _assertNonFlushedCount(int expectedCount, AnalysisCache cache) { | 136 void _assertNonFlushedCount(int expectedCount, AnalysisCache cache) { |
| 137 int nonFlushedCount = 0; | 137 int nonFlushedCount = 0; |
| 138 MapIterator<Source, SourceEntry> iterator = cache.iterator(); | 138 MapIterator<Source, SourceEntry> iterator = cache.iterator(); |
| 139 while (iterator.moveNext()) { | 139 while (iterator.moveNext()) { |
| (...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1613 JUnitTestCase.assertEquals(options.cacheSize, result.cacheSize); | 1613 JUnitTestCase.assertEquals(options.cacheSize, result.cacheSize); |
| 1614 JUnitTestCase.assertEquals(options.dart2jsHint, result.dart2jsHint); | 1614 JUnitTestCase.assertEquals(options.dart2jsHint, result.dart2jsHint); |
| 1615 JUnitTestCase.assertEquals(options.hint, result.hint); | 1615 JUnitTestCase.assertEquals(options.hint, result.hint); |
| 1616 } | 1616 } |
| 1617 | 1617 |
| 1618 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { | 1618 void test_setAnalysisOptions_reduceAnalysisPriorityOrder() { |
| 1619 AnalysisOptionsImpl options = | 1619 AnalysisOptionsImpl options = |
| 1620 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1620 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1621 List<Source> sources = new List<Source>(); | 1621 List<Source> sources = new List<Source>(); |
| 1622 for (int index = 0; index < options.cacheSize; index++) { | 1622 for (int index = 0; index < options.cacheSize; index++) { |
| 1623 sources.add(_addSource("/lib.dart${index}", "")); | 1623 sources.add(_addSource("/lib.dart$index", "")); |
| 1624 } | 1624 } |
| 1625 _context.analysisPriorityOrder = sources; | 1625 _context.analysisPriorityOrder = sources; |
| 1626 int oldPriorityOrderSize = _getPriorityOrder(_context).length; | 1626 int oldPriorityOrderSize = _getPriorityOrder(_context).length; |
| 1627 options.cacheSize = options.cacheSize - 10; | 1627 options.cacheSize = options.cacheSize - 10; |
| 1628 _context.analysisOptions = options; | 1628 _context.analysisOptions = options; |
| 1629 JUnitTestCase.assertTrue( | 1629 JUnitTestCase.assertTrue( |
| 1630 oldPriorityOrderSize > _getPriorityOrder(_context).length); | 1630 oldPriorityOrderSize > _getPriorityOrder(_context).length); |
| 1631 } | 1631 } |
| 1632 | 1632 |
| 1633 void test_setAnalysisPriorityOrder_empty() { | 1633 void test_setAnalysisPriorityOrder_empty() { |
| 1634 _context.analysisPriorityOrder = new List<Source>(); | 1634 _context.analysisPriorityOrder = new List<Source>(); |
| 1635 } | 1635 } |
| 1636 | 1636 |
| 1637 void test_setAnalysisPriorityOrder_lessThanCacheSize() { | 1637 void test_setAnalysisPriorityOrder_lessThanCacheSize() { |
| 1638 AnalysisOptions options = _context.analysisOptions; | 1638 AnalysisOptions options = _context.analysisOptions; |
| 1639 List<Source> sources = new List<Source>(); | 1639 List<Source> sources = new List<Source>(); |
| 1640 for (int index = 0; index < options.cacheSize; index++) { | 1640 for (int index = 0; index < options.cacheSize; index++) { |
| 1641 sources.add(_addSource("/lib.dart${index}", "")); | 1641 sources.add(_addSource("/lib.dart$index", "")); |
| 1642 } | 1642 } |
| 1643 _context.analysisPriorityOrder = sources; | 1643 _context.analysisPriorityOrder = sources; |
| 1644 JUnitTestCase.assertTrue( | 1644 JUnitTestCase.assertTrue( |
| 1645 options.cacheSize > _getPriorityOrder(_context).length); | 1645 options.cacheSize > _getPriorityOrder(_context).length); |
| 1646 } | 1646 } |
| 1647 | 1647 |
| 1648 void test_setAnalysisPriorityOrder_nonEmpty() { | 1648 void test_setAnalysisPriorityOrder_nonEmpty() { |
| 1649 List<Source> sources = new List<Source>(); | 1649 List<Source> sources = new List<Source>(); |
| 1650 sources.add(_addSource("/lib.dart", "library lib;")); | 1650 sources.add(_addSource("/lib.dart", "library lib;")); |
| 1651 _context.analysisPriorityOrder = sources; | 1651 _context.analysisPriorityOrder = sources; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1829 void xtest_performAnalysisTask_stress() { | 1829 void xtest_performAnalysisTask_stress() { |
| 1830 int maxCacheSize = 4; | 1830 int maxCacheSize = 4; |
| 1831 AnalysisOptionsImpl options = | 1831 AnalysisOptionsImpl options = |
| 1832 new AnalysisOptionsImpl.con1(_context.analysisOptions); | 1832 new AnalysisOptionsImpl.con1(_context.analysisOptions); |
| 1833 options.cacheSize = maxCacheSize; | 1833 options.cacheSize = maxCacheSize; |
| 1834 _context.analysisOptions = options; | 1834 _context.analysisOptions = options; |
| 1835 int sourceCount = maxCacheSize + 2; | 1835 int sourceCount = maxCacheSize + 2; |
| 1836 List<Source> sources = new List<Source>(); | 1836 List<Source> sources = new List<Source>(); |
| 1837 ChangeSet changeSet = new ChangeSet(); | 1837 ChangeSet changeSet = new ChangeSet(); |
| 1838 for (int i = 0; i < sourceCount; i++) { | 1838 for (int i = 0; i < sourceCount; i++) { |
| 1839 Source source = _addSource("/lib${i}.dart", "library lib${i};"); | 1839 Source source = _addSource("/lib$i.dart", "library lib$i;"); |
| 1840 sources.add(source); | 1840 sources.add(source); |
| 1841 changeSet.addedSource(source); | 1841 changeSet.addedSource(source); |
| 1842 } | 1842 } |
| 1843 _context.applyChanges(changeSet); | 1843 _context.applyChanges(changeSet); |
| 1844 _context.analysisPriorityOrder = sources; | 1844 _context.analysisPriorityOrder = sources; |
| 1845 for (int i = 0; i < 1000; i++) { | 1845 for (int i = 0; i < 1000; i++) { |
| 1846 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; | 1846 List<ChangeNotice> notice = _context.performAnalysisTask().changeNotices; |
| 1847 if (notice == null) { | 1847 if (notice == null) { |
| 1848 //System.out.println("test_performAnalysisTask_stress: " + i); | 1848 //System.out.println("test_performAnalysisTask_stress: " + i); |
| 1849 break; | 1849 break; |
| (...skipping 2803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4653 TopLevelVariableDeclaration fooDecl = | 4653 TopLevelVariableDeclaration fooDecl = |
| 4654 declarations[1] as TopLevelVariableDeclaration; | 4654 declarations[1] as TopLevelVariableDeclaration; |
| 4655 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; | 4655 SimpleIdentifier fooName = fooDecl.variables.variables[0].name; |
| 4656 JUnitTestCase.assertEquals("foo", fooName.name); | 4656 JUnitTestCase.assertEquals("foo", fooName.name); |
| 4657 JUnitTestCase.assertNotNull(fooName.staticElement); | 4657 JUnitTestCase.assertNotNull(fooName.staticElement); |
| 4658 // assert element reference is preserved | 4658 // assert element reference is preserved |
| 4659 } | 4659 } |
| 4660 | 4660 |
| 4661 CompilationUnit _assertTask(String prefix, String removed, String added, | 4661 CompilationUnit _assertTask(String prefix, String removed, String added, |
| 4662 String suffix) { | 4662 String suffix) { |
| 4663 String oldCode = "${prefix}${removed}${suffix}"; | 4663 String oldCode = "$prefix$removed$suffix"; |
| 4664 String newCode = "${prefix}${added}${suffix}"; | 4664 String newCode = "$prefix$added$suffix"; |
| 4665 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); | 4665 InternalAnalysisContext context = AnalysisContextFactory.contextWithCore(); |
| 4666 Source source = new TestSource("/test.dart", oldCode); | 4666 Source source = new TestSource("/test.dart", oldCode); |
| 4667 DartEntry entry = new DartEntry(); | 4667 DartEntry entry = new DartEntry(); |
| 4668 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); | 4668 CompilationUnit oldUnit = context.resolveCompilationUnit2(source, source); |
| 4669 JUnitTestCase.assertNotNull(oldUnit); | 4669 JUnitTestCase.assertNotNull(oldUnit); |
| 4670 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); | 4670 entry.setValueInLibrary(DartEntry.RESOLVED_UNIT, source, oldUnit); |
| 4671 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( | 4671 IncrementalAnalysisCache cache = IncrementalAnalysisCache.update( |
| 4672 null, | 4672 null, |
| 4673 source, | 4673 source, |
| 4674 oldCode, | 4674 oldCode, |
| (...skipping 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7077 partition.remove(source); | 7077 partition.remove(source); |
| 7078 JUnitTestCase.assertNull(partition.get(source)); | 7078 JUnitTestCase.assertNull(partition.get(source)); |
| 7079 } | 7079 } |
| 7080 void test_setMaxCacheSize() { | 7080 void test_setMaxCacheSize() { |
| 7081 UniversalCachePartition partition = new UniversalCachePartition( | 7081 UniversalCachePartition partition = new UniversalCachePartition( |
| 7082 null, | 7082 null, |
| 7083 8, | 7083 8, |
| 7084 new _UniversalCachePartitionTest_test_setMaxCacheSize()); | 7084 new _UniversalCachePartitionTest_test_setMaxCacheSize()); |
| 7085 int size = 6; | 7085 int size = 6; |
| 7086 for (int i = 0; i < size; i++) { | 7086 for (int i = 0; i < size; i++) { |
| 7087 Source source = new TestSource("/test${i}.dart"); | 7087 Source source = new TestSource("/test$i.dart"); |
| 7088 DartEntry entry = new DartEntry(); | 7088 DartEntry entry = new DartEntry(); |
| 7089 entry.setValue(DartEntry.PARSED_UNIT, null); | 7089 entry.setValue(DartEntry.PARSED_UNIT, null); |
| 7090 partition.put(source, entry); | 7090 partition.put(source, entry); |
| 7091 partition.accessedAst(source); | 7091 partition.accessedAst(source); |
| 7092 } | 7092 } |
| 7093 _assertNonFlushedCount(size, partition); | 7093 _assertNonFlushedCount(size, partition); |
| 7094 int newSize = size - 2; | 7094 int newSize = size - 2; |
| 7095 partition.maxCacheSize = newSize; | 7095 partition.maxCacheSize = newSize; |
| 7096 _assertNonFlushedCount(newSize, partition); | 7096 _assertNonFlushedCount(newSize, partition); |
| 7097 } | 7097 } |
| 7098 void test_size() { | 7098 void test_size() { |
| 7099 UniversalCachePartition partition = | 7099 UniversalCachePartition partition = |
| 7100 new UniversalCachePartition(null, 8, null); | 7100 new UniversalCachePartition(null, 8, null); |
| 7101 int size = 4; | 7101 int size = 4; |
| 7102 for (int i = 0; i < size; i++) { | 7102 for (int i = 0; i < size; i++) { |
| 7103 Source source = new TestSource("/test${i}.dart"); | 7103 Source source = new TestSource("/test$i.dart"); |
| 7104 partition.put(source, new DartEntry()); | 7104 partition.put(source, new DartEntry()); |
| 7105 partition.accessedAst(source); | 7105 partition.accessedAst(source); |
| 7106 } | 7106 } |
| 7107 JUnitTestCase.assertEquals(size, partition.size()); | 7107 JUnitTestCase.assertEquals(size, partition.size()); |
| 7108 } | 7108 } |
| 7109 void _assertNonFlushedCount(int expectedCount, | 7109 void _assertNonFlushedCount(int expectedCount, |
| 7110 UniversalCachePartition partition) { | 7110 UniversalCachePartition partition) { |
| 7111 int nonFlushedCount = 0; | 7111 int nonFlushedCount = 0; |
| 7112 Map<Source, SourceEntry> entryMap = partition.map; | 7112 Map<Source, SourceEntry> entryMap = partition.map; |
| 7113 entryMap.values.forEach((SourceEntry value) { | 7113 entryMap.values.forEach((SourceEntry value) { |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7208 } | 7208 } |
| 7209 } | 7209 } |
| 7210 | 7210 |
| 7211 | 7211 |
| 7212 class _UniversalCachePartitionTest_test_setMaxCacheSize implements | 7212 class _UniversalCachePartitionTest_test_setMaxCacheSize implements |
| 7213 CacheRetentionPolicy { | 7213 CacheRetentionPolicy { |
| 7214 @override | 7214 @override |
| 7215 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => | 7215 RetentionPriority getAstPriority(Source source, SourceEntry sourceEntry) => |
| 7216 RetentionPriority.LOW; | 7216 RetentionPriority.LOW; |
| 7217 } | 7217 } |
| OLD | NEW |