OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 library mock_compiler; | 5 library mock_compiler; |
6 | 6 |
7 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 | 10 |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 Future<Uri> init([String mainSource = ""]) { | 150 Future<Uri> init([String mainSource = ""]) { |
151 Uri uri = new Uri(scheme: "mock"); | 151 Uri uri = new Uri(scheme: "mock"); |
152 registerSource(uri, mainSource); | 152 registerSource(uri, mainSource); |
153 return libraryLoader.loadLibrary(uri) | 153 return libraryLoader.loadLibrary(uri) |
154 .then((LibraryElement library) { | 154 .then((LibraryElement library) { |
155 mainApp = library; | 155 mainApp = library; |
156 // We need to make sure the Object class is resolved. When registering a | 156 // We need to make sure the Object class is resolved. When registering a |
157 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 157 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
158 // the interfaces of the Object class which would be 'null' if the class | 158 // the interfaces of the Object class which would be 'null' if the class |
159 // wasn't resolved. | 159 // wasn't resolved. |
160 objectClass.ensureResolved(resolution); | 160 coreClasses.objectClass.ensureResolved(resolution); |
161 }).then((_) => uri); | 161 }).then((_) => uri); |
162 } | 162 } |
163 | 163 |
164 Future runCompiler(Uri uri, [String mainSource = ""]) { | 164 Future runCompiler(Uri uri, [String mainSource = ""]) { |
165 return init(mainSource).then((Uri mainUri) { | 165 return init(mainSource).then((Uri mainUri) { |
166 return super.runCompiler(uri == null ? mainUri : uri); | 166 return super.runCompiler(uri == null ? mainUri : uri); |
167 }).then((result) { | 167 }).then((result) { |
168 if (expectedErrors != null && | 168 if (expectedErrors != null && |
169 expectedErrors != errors.length) { | 169 expectedErrors != errors.length) { |
170 throw "unexpected error during compilation ${errors}"; | 170 throw "unexpected error during compilation ${errors}"; |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 trustTypeAnnotations: trustTypeAnnotations, | 468 trustTypeAnnotations: trustTypeAnnotations, |
469 enableTypeAssertions: enableTypeAssertions, | 469 enableTypeAssertions: enableTypeAssertions, |
470 enableUserAssertions: enableUserAssertions, | 470 enableUserAssertions: enableUserAssertions, |
471 expectedErrors: expectedErrors, | 471 expectedErrors: expectedErrors, |
472 expectedWarnings: expectedWarnings, | 472 expectedWarnings: expectedWarnings, |
473 outputProvider: outputProvider); | 473 outputProvider: outputProvider); |
474 compiler.registerSource(uri, code); | 474 compiler.registerSource(uri, code); |
475 compiler.diagnosticHandler = createHandler(compiler, code); | 475 compiler.diagnosticHandler = createHandler(compiler, code); |
476 return compiler; | 476 return compiler; |
477 } | 477 } |
OLD | NEW |