| 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library test.kernel.closures.suite; | 5 library test.kernel.closures.suite; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:io' show Directory, File, Platform; | 9 import 'dart:io' show Directory, File, Platform; |
| 10 | 10 |
| 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 12 | 12 |
| 13 import 'package:kernel/analyzer/loader.dart' | 13 import 'package:kernel/analyzer/loader.dart' |
| 14 show DartLoader, DartOptions, createDartSdk; | 14 show DartLoader, DartOptions, createDartSdk; |
| 15 | 15 |
| 16 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; | 16 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| 17 | 17 |
| 18 import 'package:kernel/repository.dart' show Repository; | |
| 19 | |
| 20 import 'kernel_chain.dart' | 18 import 'kernel_chain.dart' |
| 21 show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill; | 19 show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill; |
| 22 | 20 |
| 23 import 'package:testing/testing.dart' | 21 import 'package:testing/testing.dart' |
| 24 show | 22 show |
| 25 Chain, | 23 Chain, |
| 26 ChainContext, | 24 ChainContext, |
| 27 Result, | 25 Result, |
| 28 StdioProcess, | 26 StdioProcess, |
| 29 Step, | 27 Step, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const Print(), | 61 const Print(), |
| 64 const SanityCheck(), | 62 const SanityCheck(), |
| 65 new MatchExpectation(".expect", | 63 new MatchExpectation(".expect", |
| 66 updateExpectations: updateExpectations), | 64 updateExpectations: updateExpectations), |
| 67 const WriteDill(), | 65 const WriteDill(), |
| 68 const ReadDill(), | 66 const ReadDill(), |
| 69 const Run(), | 67 const Run(), |
| 70 ]; | 68 ]; |
| 71 | 69 |
| 72 Future<DartLoader> createLoader() async { | 70 Future<DartLoader> createLoader() async { |
| 73 Repository repository = new Repository(); | 71 Program repository = new Program(); |
| 74 return new DartLoader(repository, options, await loadPackagesFile(packages), | 72 return new DartLoader(repository, options, await loadPackagesFile(packages), |
| 75 dartSdk: dartSdk); | 73 dartSdk: dartSdk); |
| 76 } | 74 } |
| 77 } | 75 } |
| 78 | 76 |
| 79 enum Environment { | 77 enum Environment { |
| 80 directory, | 78 directory, |
| 81 file, | 79 file, |
| 82 } | 80 } |
| 83 | 81 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 String get name => "kernel"; | 135 String get name => "kernel"; |
| 138 | 136 |
| 139 Future<Result<Program>> run( | 137 Future<Result<Program>> run( |
| 140 TestDescription description, TestContext testContext) async { | 138 TestDescription description, TestContext testContext) async { |
| 141 try { | 139 try { |
| 142 DartLoader loader = await testContext.createLoader(); | 140 DartLoader loader = await testContext.createLoader(); |
| 143 Target target = getTarget( | 141 Target target = getTarget( |
| 144 "vm", new TargetFlags(strongMode: testContext.options.strongMode)); | 142 "vm", new TargetFlags(strongMode: testContext.options.strongMode)); |
| 145 String path = description.file.path; | 143 String path = description.file.path; |
| 146 Uri uri = Uri.base.resolve(path); | 144 Uri uri = Uri.base.resolve(path); |
| 147 Program program = loader.loadProgram(uri, target: target); | 145 loader.loadProgram(uri, target: target); |
| 146 var program = loader.program; |
| 148 for (var error in loader.errors) { | 147 for (var error in loader.errors) { |
| 149 return fail(program, "$error"); | 148 return fail(program, "$error"); |
| 150 } | 149 } |
| 151 target | 150 target |
| 152 ..performModularTransformations(program) | 151 ..performModularTransformations(program) |
| 153 ..performGlobalTransformations(program); | 152 ..performGlobalTransformations(program); |
| 154 return pass(program); | 153 return pass(program); |
| 155 } catch (e, s) { | 154 } catch (e, s) { |
| 156 return crash(e, s); | 155 return crash(e, s); |
| 157 } | 156 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 186 .run(context.vm.toFilePath(), [generated.path, "Hello, World!"]); | 185 .run(context.vm.toFilePath(), [generated.path, "Hello, World!"]); |
| 187 print(process.output); | 186 print(process.output); |
| 188 } finally { | 187 } finally { |
| 189 generated.parent.delete(recursive: true); | 188 generated.parent.delete(recursive: true); |
| 190 } | 189 } |
| 191 return process.toResult(); | 190 return process.toResult(); |
| 192 } | 191 } |
| 193 } | 192 } |
| 194 | 193 |
| 195 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); | 194 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); |
| OLD | NEW |