Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: pkg/kernel/test/closures/suite.dart

Issue 2891053003: Add support for converted closures with explicit contexts to VM (Closed)
Patch Set: Temporarily disable Run step in closures test suite Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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:io' show File;
8
7 import 'dart:async' show Future; 9 import 'dart:async' show Future;
8 10
9 import 'package:kernel/core_types.dart' show CoreTypes; 11 import 'package:kernel/core_types.dart' show CoreTypes;
10 12
11 import 'package:testing/testing.dart' 13 import 'package:testing/testing.dart'
12 show Chain, ChainContext, Result, Step, runMe; 14 show Chain, ChainContext, Result, Step, runMe, StdioProcess;
13 15
14 import 'package:kernel/ast.dart' show Program, Library; 16 import 'package:kernel/ast.dart' show Program, Library;
15 17
16 import 'package:kernel/target/targets.dart' show Target; 18 import 'package:kernel/target/targets.dart' show Target;
17 19
18 import 'package:kernel/transformations/closure_conversion.dart'
19 as closure_conversion;
20
21 import 'package:front_end/src/fasta/testing/kernel_chain.dart' 20 import 'package:front_end/src/fasta/testing/kernel_chain.dart'
22 show 21 show
23 Print, 22 Print,
24 MatchExpectation, 23 MatchExpectation,
25 WriteDill, 24 WriteDill,
26 ReadDill, 25 ReadDill,
27 Verify, 26 Verify,
28 Compile, 27 Compile,
29 CompileContext; 28 CompileContext;
30 29
30 import 'package:kernel/transformations/closure_conversion.dart'
31 as closure_conversion;
32
33 import 'package:front_end/src/fasta/testing/patched_sdk_location.dart'
34 show computePatchedSdk, computeDartVm;
35
31 const String STRONG_MODE = " strong mode "; 36 const String STRONG_MODE = " strong mode ";
32 37
33 class ClosureConversionContext extends ChainContext implements CompileContext { 38 class ClosureConversionContext extends ChainContext implements CompileContext {
34 final bool strongMode; 39 final bool strongMode;
35 Target get target => null; 40 Target get target => null;
36 41
37 final List<Step> steps; 42 final List<Step> steps;
38 43
44 Program platform;
45
39 ClosureConversionContext(this.strongMode, bool updateExpectations) 46 ClosureConversionContext(this.strongMode, bool updateExpectations)
40 : steps = <Step>[ 47 : steps = <Step>[
41 const Compile(), 48 const Compile(),
42 const Print(), 49 const Print(),
43 const Verify(true), 50 const Verify(true),
44 const ClosureConversion(), 51 const ClosureConversion(),
45 const Print(), 52 const Print(),
46 const Verify(true), 53 const Verify(true),
47 new MatchExpectation(".expect", 54 new MatchExpectation(".expect",
48 updateExpectations: updateExpectations), 55 updateExpectations: updateExpectations),
49 const WriteDill(), 56 const WriteDill(),
50 const ReadDill(), 57 const ReadDill(),
51 // TODO(29143): add `Run` step when Vectors are added to VM. 58 // TODO(29143): add `Run` step when Vectors are added to VM.
59 //const Run(),
52 ]; 60 ];
53 61
54 static Future<ClosureConversionContext> create( 62 static Future<ClosureConversionContext> create(
55 Chain suite, Map<String, String> environment) async { 63 Chain suite, Map<String, String> environment) async {
56 bool strongMode = environment.containsKey(STRONG_MODE); 64 bool strongMode = environment.containsKey(STRONG_MODE);
57 bool updateExpectations = environment["updateExpectations"] == "true"; 65 bool updateExpectations = environment["updateExpectations"] == "true";
58 return new ClosureConversionContext(strongMode, updateExpectations); 66 return new ClosureConversionContext(strongMode, updateExpectations);
59 } 67 }
60 } 68 }
61 69
(...skipping 17 matching lines...) Expand all
79 Library library = program.libraries 87 Library library = program.libraries
80 .firstWhere((Library library) => library.importUri.scheme != "dart"); 88 .firstWhere((Library library) => library.importUri.scheme != "dart");
81 closure_conversion.transformLibraries(coreTypes, <Library>[library]); 89 closure_conversion.transformLibraries(coreTypes, <Library>[library]);
82 return pass(program); 90 return pass(program);
83 } catch (e, s) { 91 } catch (e, s) {
84 return crash(e, s); 92 return crash(e, s);
85 } 93 }
86 } 94 }
87 } 95 }
88 96
97 class Run extends Step<Uri, int, ClosureConversionContext> {
98 const Run();
99
100 String get name => "run";
101
102 Future<Result<int>> run(Uri uri, ClosureConversionContext context) async {
103 final File generated = new File.fromUri(uri);
104 try {
105 Uri sdk = await computePatchedSdk();
106 Uri vm = computeDartVm(sdk);
107 final StdioProcess process = await StdioProcess
108 .run(vm.toFilePath(), [generated.path, "Hello, World!"]);
109 print(process.output);
110 return process.toResult();
111 } finally {
112 generated.parent.delete(recursive: true);
113 }
114 }
115 }
116
89 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); 117 main(List<String> arguments) => runMe(arguments, createContext, "testing.json");
OLDNEW
« no previous file with comments | « pkg/kernel/test/closures/closures.status ('k') | pkg/kernel/testcases/closures/capture_this.dart.expect » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698