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

Side by Side Diff: pkg/front_end/lib/src/fasta/testing/suite.dart

Issue 2726843003: Rename FeContext to FastaContext. (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/compile_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 fasta.testing.suite; 5 library fasta.testing.suite;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 String shortenAstKindName(AstKind astKind) { 56 String shortenAstKindName(AstKind astKind) {
57 switch (astKind) { 57 switch (astKind) {
58 case AstKind.Analyzer: 58 case AstKind.Analyzer:
59 return "dartk"; 59 return "dartk";
60 case AstKind.Kernel: 60 case AstKind.Kernel:
61 return "direct"; 61 return "direct";
62 } 62 }
63 throw "Unknown AST kind: $astKind"; 63 throw "Unknown AST kind: $astKind";
64 } 64 }
65 65
66 class FeContext extends TestContext { 66 class FastaContext extends TestContext {
67 final TranslateUri uriTranslator; 67 final TranslateUri uriTranslator;
68 68
69 final List<Step> steps; 69 final List<Step> steps;
70 70
71 final ExpectationSet expectationSet = 71 final ExpectationSet expectationSet =
72 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS)); 72 new ExpectationSet.fromJsonList(JSON.decode(EXPECTATIONS));
73 73
74 Future<Program> platform; 74 Future<Program> platform;
75 75
76 FeContext( 76 FastaContext(
77 Uri sdk, 77 Uri sdk,
78 Uri vm, 78 Uri vm,
79 Uri packages, 79 Uri packages,
80 bool strongMode, 80 bool strongMode,
81 DartSdk dartSdk, 81 DartSdk dartSdk,
82 bool updateExpectations, 82 bool updateExpectations,
83 this.uriTranslator, 83 this.uriTranslator,
84 bool fullCompile, 84 bool fullCompile,
85 AstKind astKind) 85 AstKind astKind)
86 : steps = <Step>[ 86 : steps = <Step>[
(...skipping 28 matching lines...) Expand all
115 program.uriToSource.remove(mainLibrary.fileUri); 115 program.uriToSource.remove(mainLibrary.fileUri);
116 program = new Program( 116 program = new Program(
117 program.libraries.where((Library l) => l != mainLibrary).toList(), 117 program.libraries.where((Library l) => l != mainLibrary).toList(),
118 program.uriToSource); 118 program.uriToSource);
119 target.performModularTransformations(program); 119 target.performModularTransformations(program);
120 target.performGlobalTransformations(program); 120 target.performGlobalTransformations(program);
121 return program; 121 return program;
122 }); 122 });
123 } 123 }
124 124
125 static Future<FeContext> create( 125 static Future<FastaContext> create(
126 Chain suite, 126 Chain suite, Map<String, String> environment) async {
127 Map<String, String> environment, 127 return TestContext.create(suite, environment, (Chain suite,
128 Uri sdk, 128 Map<String, String> environment,
129 Uri vm, 129 Uri sdk,
130 Uri packages, 130 Uri vm,
131 bool strongMode, 131 Uri packages,
132 DartSdk dartSdk, 132 bool strongMode,
133 bool updateExpectations) async { 133 DartSdk dartSdk,
134 TranslateUri uriTranslator = await TranslateUri.parse(packages); 134 bool updateExpectations) async {
135 String astKindString = environment[AST_KIND_INDEX]; 135 TranslateUri uriTranslator = await TranslateUri.parse(packages);
136 AstKind astKind = 136 String astKindString = environment[AST_KIND_INDEX];
137 astKindString == null ? null : AstKind.values[int.parse(astKindString)]; 137 AstKind astKind = astKindString == null
138 return new FeContext( 138 ? null
139 sdk, 139 : AstKind.values[int.parse(astKindString)];
140 vm, 140 return new FastaContext(
141 packages, 141 sdk,
142 strongMode, 142 vm,
143 dartSdk, 143 packages,
144 updateExpectations, 144 strongMode,
145 uriTranslator, 145 dartSdk,
146 environment.containsKey(ENABLE_FULL_COMPILE), 146 updateExpectations,
147 astKind); 147 uriTranslator,
148 environment.containsKey(ENABLE_FULL_COMPILE),
149 astKind);
150 });
148 } 151 }
149 } 152 }
150 153
151 class Outline extends Step<TestDescription, Program, FeContext> { 154 class Outline extends Step<TestDescription, Program, FastaContext> {
152 final bool fullCompile; 155 final bool fullCompile;
153 156
154 final AstKind astKind; 157 final AstKind astKind;
155 158
156 const Outline(this.fullCompile, this.astKind); 159 const Outline(this.fullCompile, this.astKind);
157 160
158 String get name { 161 String get name {
159 return fullCompile ? "${shortenAstKindName(astKind)} compile" : "outline"; 162 return fullCompile ? "${shortenAstKindName(astKind)} compile" : "outline";
160 } 163 }
161 164
162 bool get isCompiler => fullCompile; 165 bool get isCompiler => fullCompile;
163 166
164 Future<Result<Program>> run( 167 Future<Result<Program>> run(
165 TestDescription description, FeContext context) async { 168 TestDescription description, FastaContext context) async {
166 Program platform = await context.createPlatform(); 169 Program platform = await context.createPlatform();
167 Ticker ticker = new Ticker(); 170 Ticker ticker = new Ticker();
168 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator); 171 DillTarget dillTarget = new DillTarget(ticker, context.uriTranslator);
169 dillTarget.loader 172 dillTarget.loader
170 ..input = Uri.parse("org.dartlang:platform") // Make up a name. 173 ..input = Uri.parse("org.dartlang:platform") // Make up a name.
171 ..setProgram(platform); 174 ..setProgram(platform);
172 KernelTarget sourceTarget = 175 KernelTarget sourceTarget =
173 new KernelTarget(dillTarget, context.uriTranslator); 176 new KernelTarget(dillTarget, context.uriTranslator);
174 Program p; 177 Program p;
175 try { 178 try {
176 sourceTarget.read(description.uri); 179 sourceTarget.read(description.uri);
177 await dillTarget.writeOutline(null); 180 await dillTarget.writeOutline(null);
178 p = await sourceTarget.writeOutline(null); 181 p = await sourceTarget.writeOutline(null);
179 if (fullCompile) { 182 if (fullCompile) {
180 p = await sourceTarget.writeProgram(null, astKind); 183 p = await sourceTarget.writeProgram(null, astKind);
181 } 184 }
182 } on InputError catch (e, s) { 185 } on InputError catch (e, s) {
183 return fail(null, e.error, s); 186 return fail(null, e.error, s);
184 } 187 }
185 return pass(p); 188 return pass(p);
186 } 189 }
187 } 190 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/test/fasta/compile_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698