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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 .then((LibraryElement library) { | 156 .then((LibraryElement library) { |
157 mainApp = library; | 157 mainApp = library; |
158 // We need to make sure the Object class is resolved. When registering a | 158 // We need to make sure the Object class is resolved. When registering a |
159 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 159 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
160 // the interfaces of the Object class which would be 'null' if the class | 160 // the interfaces of the Object class which would be 'null' if the class |
161 // wasn't resolved. | 161 // wasn't resolved. |
162 coreClasses.objectClass.ensureResolved(resolution); | 162 coreClasses.objectClass.ensureResolved(resolution); |
163 }).then((_) => uri); | 163 }).then((_) => uri); |
164 } | 164 } |
165 | 165 |
166 Future runCompiler(Uri uri, [String mainSource = ""]) { | 166 Future run(Uri uri, [String mainSource = ""]) { |
167 return init(mainSource).then((Uri mainUri) { | 167 return init(mainSource).then((Uri mainUri) { |
168 return super.runCompiler(uri == null ? mainUri : uri); | 168 return super.run(uri == null ? mainUri : uri); |
169 }).then((result) { | 169 }).then((result) { |
170 if (expectedErrors != null && | 170 if (expectedErrors != null && |
171 expectedErrors != errors.length) { | 171 expectedErrors != errors.length) { |
172 throw "unexpected error during compilation ${errors}"; | 172 throw "unexpected error during compilation ${errors}"; |
173 } else if (expectedWarnings != null && | 173 } else if (expectedWarnings != null && |
174 expectedWarnings != warnings.length) { | 174 expectedWarnings != warnings.length) { |
175 throw "unexpected warnings during compilation ${warnings}"; | 175 throw "unexpected warnings during compilation ${warnings}"; |
176 } else { | 176 } else { |
177 return result; | 177 return result; |
178 } | 178 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 trustTypeAnnotations: trustTypeAnnotations, | 470 trustTypeAnnotations: trustTypeAnnotations, |
471 enableTypeAssertions: enableTypeAssertions, | 471 enableTypeAssertions: enableTypeAssertions, |
472 enableUserAssertions: enableUserAssertions, | 472 enableUserAssertions: enableUserAssertions, |
473 expectedErrors: expectedErrors, | 473 expectedErrors: expectedErrors, |
474 expectedWarnings: expectedWarnings, | 474 expectedWarnings: expectedWarnings, |
475 outputProvider: outputProvider); | 475 outputProvider: outputProvider); |
476 compiler.registerSource(uri, code); | 476 compiler.registerSource(uri, code); |
477 compiler.diagnosticHandler = createHandler(compiler, code); | 477 compiler.diagnosticHandler = createHandler(compiler, code); |
478 return compiler; | 478 return compiler; |
479 } | 479 } |
OLD | NEW |