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

Unified Diff: dart/tests/try/poi/forget_element_test.dart

Issue 619923004: Forget closure class maps. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/constant_handler_javascript.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/tests/try/poi/forget_element_test.dart
diff --git a/dart/tests/try/poi/forget_element_test.dart b/dart/tests/try/poi/forget_element_test.dart
index 342656617d83b963c83e68c42a2ebfbb358a1998..4e06cd63e1de363b031f713593c0118c7de2fa68 100644
--- a/dart/tests/try/poi/forget_element_test.dart
+++ b/dart/tests/try/poi/forget_element_test.dart
@@ -44,13 +44,16 @@ class ForgetElementTestCase extends CompilerTestCase {
final int expectedInitialDartValueCount;
+ final int additionalClosureClassMaps;
+
ForgetElementTestCase(
String source,
{int closureCount: 0,
int metadataCount: 0,
int constantCount: 0,
int initialValueCount: 0,
- int initialDartValueCount: null})
+ int initialDartValueCount: null,
+ this.additionalClosureClassMaps: 0})
: this.expectedClosureCount = closureCount,
this.expectedMetadataCount = metadataCount,
this.expectedConstantCount = constantCount,
@@ -93,6 +96,15 @@ class ForgetElementTestCase extends CompilerTestCase {
elementsWithDartInitialValuesIn(library).length,
'number of fields with initial values (Dart)');
+ // Check that the compiler has recorded the expected number of closure
+ // class maps. There's always at least one, from main. Each top-level
+ // element also seems to induce one.
+ Expect.equals(
+ expectedClosureCount + additionalClosureClassMaps,
+ closureClassMapsIn(library).length - 1,
+ 'closure class map count ${closureClassMapsIn(library)}');
+
+
// Forget about all elements.
library.forEachLocalMember(compiler.forgetElement);
@@ -112,6 +124,9 @@ class ForgetElementTestCase extends CompilerTestCase {
Expect.isTrue(
elementsWithDartInitialValuesIn(library).isEmpty,
'fields with initial values (Dart)');
+
+ // Check that closure class maps were forgotten.
+ Expect.isTrue(closureClassMapsIn(library).isEmpty, 'closure class maps');
});
Iterable closuresInLibrary(LibraryElement library) {
@@ -171,6 +186,10 @@ class ForgetElementTestCase extends CompilerTestCase {
(VariableElement element) => element.library == library);
}
+ Iterable closureClassMapsIn(LibraryElement library) {
+ Map cache = compiler.closureToClassMapper.closureMappingCache;
+ return nodesIn(library).where((node) => cache[node] != null);
+ }
}
class NodeCollector extends tree.Visitor {
@@ -276,7 +295,8 @@ List<CompilerTestCase> get tests => <CompilerTestCase>[
'main() => x; var x = const Constant(); $CONSTANT_CLASS',
constantCount: 1,
initialValueCount: 1,
- initialDartValueCount: 0),
+ initialDartValueCount: 0,
+ additionalClosureClassMaps: 1),
// Test that a constant in a parameter initializer is discarded
// correctly.
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/constant_handler_javascript.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698