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

Unified Diff: tests/compiler/dart2js/mock_compiler.dart

Issue 10990060: Added support for exports and re-exports. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 2 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
Index: tests/compiler/dart2js/mock_compiler.dart
diff --git a/tests/compiler/dart2js/mock_compiler.dart b/tests/compiler/dart2js/mock_compiler.dart
index 908d1d8888000f7e4e31f2c643da2e4b4cd48b15..8700f9ba7ccb82dd935aa9d303661ee882002a17 100644
--- a/tests/compiler/dart2js/mock_compiler.dart
+++ b/tests/compiler/dart2js/mock_compiler.dart
@@ -81,26 +81,30 @@ class MockCompiler extends Compiler {
: warnings = [], errors = [],
sourceFiles = new Map<String, SourceFile>(),
super(enableTypeAssertions: enableTypeAssertions) {
- Uri uri = new Uri.fromComponents(scheme: "source");
- var script = new Script(uri, new MockFile(coreSource));
- coreLibrary = new LibraryElement(script);
- parseScript(coreSource, coreLibrary);
+ coreLibrary = createLibrary("core", coreSource);
// We need to set the assert method to avoid calls with a 'null'
// target being interpreted as a call to assert.
-
- script = new Script(uri, new MockFile(helperSource));
- jsHelperLibrary = new LibraryElement(script);
- parseScript(helperSource, jsHelperLibrary);
+ jsHelperLibrary = createLibrary("helper", helperSource);
assertMethod = jsHelperLibrary.find(buildSourceString('assert'));
-
- script = new Script(uri, new MockFile(interceptorsSource));
- interceptorsLibrary = new LibraryElement(script);
- parseScript(interceptorsSource, interceptorsLibrary);
+ interceptorsLibrary = createLibrary("interceptors", interceptorsSource);
mainApp = mockLibrary(this, "");
initializeSpecialClasses();
}
+ /**
+ * Used internally to create a library from a source text. The created library
+ * is fixed to export its top-level declarations.
+ */
+ LibraryElement createLibrary(String name, String source) {
+ Uri uri = new Uri.fromComponents(scheme: "source", path: name);
+ var script = new Script(uri, new MockFile(source));
+ var library = new LibraryElement(script);
+ parseScript(source, library);
+ library.setExports(library.localScope.getValues());
+ return library;
+ }
+
void reportWarning(Node node, var message) {
warnings.add(new WarningMessage(node, message.message));
}

Powered by Google App Engine
This is Rietveld 408576698