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

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

Issue 613963002: Flush cached data in JavaScriptConstantCompiler.metadataConstantMap. (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/js_backend.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 e60126c799099469a0d340fce76ac31d26027c4b..ba9aadf99bc0794dc1600d185a75a32bf0780123 100644
--- a/dart/tests/try/poi/forget_element_test.dart
+++ b/dart/tests/try/poi/forget_element_test.dart
@@ -6,45 +6,74 @@
library trydart.forget_element_test;
import 'package:compiler/implementation/elements/elements.dart' show
- LocalFunctionElement;
+ LocalFunctionElement,
+ MetadataAnnotation;
+
+import 'package:compiler/implementation/js_backend/js_backend.dart' show
+ JavaScriptBackend;
import 'compiler_test_case.dart';
class ForgetElementTestCase extends CompilerTestCase {
final int expectedClosureCount;
- ForgetElementTestCase(String source, {int closureCount})
+ final int expectedMetadataCount;
+
+ ForgetElementTestCase(
+ String source,
+ {int closureCount: 0,
+ int metadataCount: 0})
: this.expectedClosureCount = closureCount,
+ this.expectedMetadataCount = metadataCount,
super(source);
Future run() => compile().then((LibraryElement library) {
// Check that the compiler has recorded the expected number of closures.
- Expect.equals(expectedClosureCount, closuresInLibrary(library).length);
+ Expect.equals(
+ expectedClosureCount, closuresInLibrary(library).length,
+ 'closure count');
+
+ // Check that the compiler has recorded the expected number of metadata
+ // annotations.
+ Expect.equals(
+ expectedMetadataCount, metadataInLibrary(library).length,
+ 'metadata count');
// Forget about all elements.
library.forEachLocalMember(compiler.forgetElement);
// Check that all the closures were forgotten.
- Expect.isTrue(closuresInLibrary(library).isEmpty);
+ Expect.isTrue(closuresInLibrary(library).isEmpty, 'closures');
+
+ // Check that the metadata annotations were forgotten.
+ Expect.isTrue(metadataInLibrary(library).isEmpty, 'metadata');
});
Iterable closuresInLibrary(LibraryElement library) {
return compiler.enqueuer.resolution.universe.allClosures.where(
(LocalFunctionElement closure) => closure.library == library);
}
+
+ Iterable metadataInLibrary(LibraryElement library) {
+ JavaScriptBackend backend = compiler.backend;
+ return backend.constants.metadataConstantMap.keys.where(
+ (MetadataAnnotation metadata) {
+ return metadata.annotatedElement.library == library;
+ });
+ }
}
+const String CONSTANT_CLASS = 'class Constant { const Constant(); }';
+
void main() {
runTests(
[
new ForgetElementTestCase(
- 'main() {}',
- closureCount: 0),
+ 'main() {}'),
new ForgetElementTestCase(
- 'main() => null;',
- closureCount: 0),
+ 'main() => null;'),
new ForgetElementTestCase(
'main() => (() => null)();',
@@ -57,6 +86,15 @@ void main() {
new ForgetElementTestCase(
'main() => (() => (() => (() => null)())())();',
closureCount: 3),
+
+ new ForgetElementTestCase(
+ '@Constant() main() => null; $CONSTANT_CLASS',
+ metadataCount: 1),
+
+ new ForgetElementTestCase(
+ 'main() => ((@Constant() x) => x)(null); $CONSTANT_CLASS',
+ closureCount: 1,
+ metadataCount: 1),
]
);
}
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/js_backend.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698