| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 dart_backend.test_helper; | 5 library dart_backend.test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
| 9 import 'package:compiler/compiler.dart' as api; |
| 9 import 'package:compiler/src/dart2jslib.dart'; | 10 import 'package:compiler/src/dart2jslib.dart'; |
| 10 import '../../../../pkg/analyzer2dart/test/test_helper.dart'; | 11 import '../../../../pkg/analyzer2dart/test/test_helper.dart'; |
| 11 import '../compiler_helper.dart'; | 12 import '../compiler_helper.dart'; |
| 12 | 13 |
| 13 /// Compiles the given dart code (which must include a 'main' function) and | 14 /// Compiles the given dart code (which must include a 'main' function) and |
| 14 /// returns the compiler. | 15 /// returns the compiler. |
| 15 Future<Compiler> compilerFor(String code) { | 16 Future<Compiler> compilerFor(String code, |
| 17 {api.CompilerOutputProvider outputProvider}) { |
| 16 MockCompiler compiler = new MockCompiler.internal( | 18 MockCompiler compiler = new MockCompiler.internal( |
| 17 emitJavaScript: false, | 19 emitJavaScript: false, |
| 18 enableMinification: false); | 20 enableMinification: false, |
| 21 outputProvider: outputProvider); |
| 19 compiler.diagnosticHandler = createHandler(compiler, code); | 22 compiler.diagnosticHandler = createHandler(compiler, code); |
| 20 return compiler.init().then((_) { | 23 return compiler.init().then((_) { |
| 21 compiler.parseScript(code); | 24 compiler.parseScript(code); |
| 22 | 25 |
| 23 Element element = compiler.mainApp.find('main'); | 26 Element element = compiler.mainApp.find('main'); |
| 24 if (element == null) return null; | 27 if (element == null) return null; |
| 25 | 28 |
| 26 compiler.mainFunction = element; | 29 compiler.mainFunction = element; |
| 27 compiler.phase = Compiler.PHASE_RESOLVING; | 30 compiler.phase = Compiler.PHASE_RESOLVING; |
| 28 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution, | 31 compiler.backend.enqueueHelpers(compiler.enqueuer.resolution, |
| 29 compiler.globalDependencies); | 32 compiler.globalDependencies); |
| 30 compiler.processQueue(compiler.enqueuer.resolution, element); | 33 compiler.processQueue(compiler.enqueuer.resolution, element); |
| 31 compiler.world.populate(); | 34 compiler.world.populate(); |
| 32 compiler.backend.onResolutionComplete(); | 35 compiler.backend.onResolutionComplete(); |
| 33 | 36 |
| 34 compiler.irBuilder.buildNodes(); | 37 compiler.irBuilder.buildNodes(); |
| 35 | 38 |
| 36 return compiler; | 39 return compiler; |
| 37 }); | 40 }); |
| 38 } | 41 } |
| 39 | 42 |
| 40 /// Test group using async_helper. | 43 /// Test group using async_helper. |
| 41 asyncTester(Group group, RunTest runTest) { | 44 asyncTester(Group group, RunTest runTest) { |
| 42 asyncTest(() => Future.forEach(group.results, runTest)); | 45 asyncTest(() => Future.forEach(group.results, runTest)); |
| 43 } | 46 } |
| OLD | NEW |