| 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));
|
| }
|
|
|