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

Side by Side Diff: compiler/javatests/com/google/dart/corelib/SharedTestCase.java

Issue 9113017: Add unitAboutToCompile() into DartCompilerListener (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 package com.google.dart.corelib; 5 package com.google.dart.corelib;
6 6
7 import com.google.dart.compiler.CommandLineOptions.CompilerOptions; 7 import com.google.dart.compiler.CommandLineOptions.CompilerOptions;
8 import com.google.dart.compiler.ast.DartUnit;
9 import com.google.dart.compiler.CompilerConfiguration; 8 import com.google.dart.compiler.CompilerConfiguration;
10 import com.google.dart.compiler.DartArtifactProvider; 9 import com.google.dart.compiler.DartArtifactProvider;
11 import com.google.dart.compiler.DartCompilationError; 10 import com.google.dart.compiler.DartCompilationError;
12 import com.google.dart.compiler.DartCompiler; 11 import com.google.dart.compiler.DartCompiler;
13 import com.google.dart.compiler.DartCompilerListener; 12 import com.google.dart.compiler.DartCompilerListener;
14 import com.google.dart.compiler.DefaultCompilerConfiguration; 13 import com.google.dart.compiler.DefaultCompilerConfiguration;
15 import com.google.dart.compiler.DefaultDartArtifactProvider; 14 import com.google.dart.compiler.DefaultDartArtifactProvider;
16 import com.google.dart.compiler.DefaultLibrarySource; 15 import com.google.dart.compiler.DefaultLibrarySource;
17 import com.google.dart.compiler.ErrorSeverity; 16 import com.google.dart.compiler.ErrorSeverity;
18 import com.google.dart.compiler.LibrarySource; 17 import com.google.dart.compiler.LibrarySource;
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 CharArrayWriter writer = artifacts.get(uri); 210 CharArrayWriter writer = artifacts.get(uri);
212 if (writer != null) { 211 if (writer != null) {
213 return new CharArrayReader(writer.toCharArray()); 212 return new CharArrayReader(writer.toCharArray());
214 } 213 }
215 return provider.getArtifactReader(source, part, extension); 214 return provider.getArtifactReader(source, part, extension);
216 } 215 }
217 }; 216 };
218 } 217 }
219 218
220 private DartCompilerListener getListener() { 219 private DartCompilerListener getListener() {
221 DartCompilerListener listener = new DartCompilerListener() { 220 DartCompilerListener listener = new DartCompilerListener.Empty() {
222 @Override 221 @Override
223 public void onError(DartCompilationError event) { 222 public void onError(DartCompilationError event) {
224 if (event.getErrorCode().getSubSystem() == SubSystem.STATIC_TYPE) { 223 if (event.getErrorCode().getSubSystem() == SubSystem.STATIC_TYPE) {
225 typeErrorCount.incrementAndGet(); 224 typeErrorCount.incrementAndGet();
226 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.ERRO R) { 225 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.ERRO R) {
227 compilationErrorCount.incrementAndGet(); 226 compilationErrorCount.incrementAndGet();
228 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.WARN ING) { 227 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.WARN ING) {
229 warningCount.incrementAndGet(); 228 warningCount.incrementAndGet();
230 } 229 }
231 maybeThrow(event); 230 maybeThrow(event);
232 } 231 }
233 232
234 private void maybeThrow(DartCompilationError event) { 233 private void maybeThrow(DartCompilationError event) {
235 if (isNegative) { 234 if (isNegative) {
236 return; 235 return;
237 } 236 }
238 if (outcomes.contains("pass")) { 237 if (outcomes.contains("pass")) {
239 // It is easier to debug a failing regular test if we throw an excepti on. 238 // It is easier to debug a failing regular test if we throw an excepti on.
240 throw new AssertionError(event); 239 throw new AssertionError(event);
241 } 240 }
242 } 241 }
243
244 @Override
245 public void unitCompiled(DartUnit unit) {
246 }
247 }; 242 };
248 return listener; 243 return listener;
249 } 244 }
250 245
251 private void analyzeNormalCompletion() { 246 private void analyzeNormalCompletion() {
252 if (isNegative) { 247 if (isNegative) {
253 if (!outcomes.contains("fail")) { 248 if (!outcomes.contains("fail")) {
254 fail("Negative test didn't cause an error"); 249 fail("Negative test didn't cause an error");
255 } 250 }
256 } else { 251 } else {
(...skipping 29 matching lines...) Expand all
286 String[] fields = SEPARATOR.split(line); 281 String[] fields = SEPARATOR.split(line);
287 assertTrue(line, fields.length > 3); 282 assertTrue(line, fields.length > 3);
288 String name = fields[0]; 283 String name = fields[0];
289 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s plit(","))); 284 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s plit(",")));
290 boolean isNegative = fields[2].equals("True"); 285 boolean isNegative = fields[2].equals("True");
291 String[] arguments = new String[fields.length - 3]; 286 String[] arguments = new String[fields.length - 3];
292 System.arraycopy(fields, 3, arguments, 0, arguments.length); 287 System.arraycopy(fields, 3, arguments, 0, arguments.length);
293 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume nts) {}; 288 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume nts) {};
294 } 289 }
295 } 290 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698