OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:compiler/compiler_new.dart' as api; | 10 import 'package:compiler/compiler_new.dart' as api; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 String get patchVersion { | 138 String get patchVersion { |
139 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; | 139 return testedPatchVersion != null ? testedPatchVersion : super.patchVersion; |
140 } | 140 } |
141 | 141 |
142 /// Initialize the mock compiler with an empty main library. | 142 /// Initialize the mock compiler with an empty main library. |
143 Future<Uri> init([String mainSource = ""]) { | 143 Future<Uri> init([String mainSource = ""]) { |
144 Uri uri = new Uri(scheme: "mock"); | 144 Uri uri = new Uri(scheme: "mock"); |
145 registerSource(uri, mainSource); | 145 registerSource(uri, mainSource); |
146 return libraryLoader.loadLibrary(uri).then((LibraryElement library) { | 146 return libraryLoader.loadLibrary(uri).then((LibraryElement library) { |
147 mainApp = library; | 147 mainApp = library; |
| 148 startResolution(); |
148 // We need to make sure the Object class is resolved. When registering a | 149 // We need to make sure the Object class is resolved. When registering a |
149 // dynamic invocation the ArgumentTypesRegistry eventually iterates over | 150 // dynamic invocation the ArgumentTypesRegistry eventually iterates over |
150 // the interfaces of the Object class which would be 'null' if the class | 151 // the interfaces of the Object class which would be 'null' if the class |
151 // wasn't resolved. | 152 // wasn't resolved. |
152 ClassElement objectClass = commonElements.objectClass; | 153 ClassElement objectClass = commonElements.objectClass; |
153 objectClass.ensureResolved(resolution); | 154 objectClass.ensureResolved(resolution); |
154 }).then((_) => uri); | 155 }).then((_) => uri); |
155 } | 156 } |
156 | 157 |
157 Future run(Uri uri, [String mainSource = ""]) { | 158 Future run(Uri uri, [String mainSource = ""]) { |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 trustTypeAnnotations: trustTypeAnnotations, | 394 trustTypeAnnotations: trustTypeAnnotations, |
394 enableTypeAssertions: enableTypeAssertions, | 395 enableTypeAssertions: enableTypeAssertions, |
395 enableUserAssertions: enableUserAssertions, | 396 enableUserAssertions: enableUserAssertions, |
396 expectedErrors: expectedErrors, | 397 expectedErrors: expectedErrors, |
397 expectedWarnings: expectedWarnings, | 398 expectedWarnings: expectedWarnings, |
398 outputProvider: outputProvider); | 399 outputProvider: outputProvider); |
399 compiler.registerSource(uri, code); | 400 compiler.registerSource(uri, code); |
400 compiler.diagnosticHandler = createHandler(compiler, code); | 401 compiler.diagnosticHandler = createHandler(compiler, code); |
401 return compiler; | 402 return compiler; |
402 } | 403 } |
OLD | NEW |