| OLD | NEW |
| 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; | 8 import com.google.dart.compiler.ast.DartUnit; |
| 9 import com.google.dart.compiler.CompilerConfiguration; | 9 import com.google.dart.compiler.CompilerConfiguration; |
| 10 import com.google.dart.compiler.DartArtifactProvider; | 10 import com.google.dart.compiler.DartArtifactProvider; |
| 11 import com.google.dart.compiler.DartCompilationError; | 11 import com.google.dart.compiler.DartCompilationError; |
| 12 import com.google.dart.compiler.DartCompiler; | 12 import com.google.dart.compiler.DartCompiler; |
| 13 import com.google.dart.compiler.DartCompilerListener; | 13 import com.google.dart.compiler.DartCompilerListener; |
| 14 import com.google.dart.compiler.DefaultCompilerConfiguration; | 14 import com.google.dart.compiler.DefaultCompilerConfiguration; |
| 15 import com.google.dart.compiler.DefaultDartArtifactProvider; | 15 import com.google.dart.compiler.DefaultDartArtifactProvider; |
| 16 import com.google.dart.compiler.DefaultLibrarySource; | 16 import com.google.dart.compiler.DefaultLibrarySource; |
| 17 import com.google.dart.compiler.ErrorSeverity; |
| 17 import com.google.dart.compiler.LibrarySource; | 18 import com.google.dart.compiler.LibrarySource; |
| 18 import com.google.dart.compiler.Source; | 19 import com.google.dart.compiler.Source; |
| 20 import com.google.dart.compiler.SubSystem; |
| 19 import com.google.dart.compiler.UrlLibrarySource; | 21 import com.google.dart.compiler.UrlLibrarySource; |
| 20 import com.google.dart.runner.DartRunner; | 22 import com.google.dart.runner.DartRunner; |
| 21 import com.google.dart.runner.RunnerError; | 23 import com.google.dart.runner.RunnerError; |
| 22 import com.google.dart.runner.V8Launcher; | 24 import com.google.dart.runner.V8Launcher; |
| 23 | 25 |
| 24 import junit.framework.AssertionFailedError; | 26 import junit.framework.AssertionFailedError; |
| 25 import junit.framework.Test; | 27 import junit.framework.Test; |
| 26 import junit.framework.TestCase; | 28 import junit.framework.TestCase; |
| 27 import junit.framework.TestSuite; | 29 import junit.framework.TestSuite; |
| 28 | 30 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 return new CharArrayReader(writer.toCharArray()); | 213 return new CharArrayReader(writer.toCharArray()); |
| 212 } | 214 } |
| 213 return provider.getArtifactReader(source, part, extension); | 215 return provider.getArtifactReader(source, part, extension); |
| 214 } | 216 } |
| 215 }; | 217 }; |
| 216 } | 218 } |
| 217 | 219 |
| 218 private DartCompilerListener getListener() { | 220 private DartCompilerListener getListener() { |
| 219 DartCompilerListener listener = new DartCompilerListener() { | 221 DartCompilerListener listener = new DartCompilerListener() { |
| 220 @Override | 222 @Override |
| 221 public void compilationError(DartCompilationError event) { | 223 public void onError(DartCompilationError event) { |
| 222 compilationErrorCount.incrementAndGet(); | 224 if (event.getErrorCode().getSubSystem() == SubSystem.STATIC_TYPE) { |
| 225 typeErrorCount.incrementAndGet(); |
| 226 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.ERRO
R) { |
| 227 compilationErrorCount.incrementAndGet(); |
| 228 } else if (event.getErrorCode().getErrorSeverity() == ErrorSeverity.WARN
ING) { |
| 229 warningCount.incrementAndGet(); |
| 230 } |
| 223 maybeThrow(event); | 231 maybeThrow(event); |
| 224 } | 232 } |
| 225 | 233 |
| 226 private void maybeThrow(DartCompilationError event) { | 234 private void maybeThrow(DartCompilationError event) { |
| 227 if (isNegative) { | 235 if (isNegative) { |
| 228 return; | 236 return; |
| 229 } | 237 } |
| 230 if (outcomes.contains("pass")) { | 238 if (outcomes.contains("pass")) { |
| 231 // It is easier to debug a failing regular test if we throw an excepti
on. | 239 // It is easier to debug a failing regular test if we throw an excepti
on. |
| 232 throw new AssertionError(event); | 240 throw new AssertionError(event); |
| 233 } | 241 } |
| 234 } | 242 } |
| 235 | 243 |
| 236 @Override | 244 @Override |
| 237 public void compilationWarning(DartCompilationError event) { | |
| 238 warningCount.incrementAndGet(); | |
| 239 maybeThrow(event); | |
| 240 } | |
| 241 | |
| 242 @Override | |
| 243 public void typeError(DartCompilationError event) { | |
| 244 typeErrorCount.incrementAndGet(); | |
| 245 maybeThrow(event); | |
| 246 } | |
| 247 | |
| 248 @Override | |
| 249 public void unitCompiled(DartUnit unit) { | 245 public void unitCompiled(DartUnit unit) { |
| 250 } | 246 } |
| 251 }; | 247 }; |
| 252 return listener; | 248 return listener; |
| 253 } | 249 } |
| 254 | 250 |
| 255 private void analyzeNormalCompletion() { | 251 private void analyzeNormalCompletion() { |
| 256 if (isNegative) { | 252 if (isNegative) { |
| 257 if (!outcomes.contains("fail")) { | 253 if (!outcomes.contains("fail")) { |
| 258 fail("Negative test didn't cause an error"); | 254 fail("Negative test didn't cause an error"); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 String[] fields = SEPARATOR.split(line); | 286 String[] fields = SEPARATOR.split(line); |
| 291 assertTrue(line, fields.length > 3); | 287 assertTrue(line, fields.length > 3); |
| 292 String name = fields[0]; | 288 String name = fields[0]; |
| 293 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s
plit(","))); | 289 Set<String> outcomes = new HashSet<String>(Arrays.<String>asList(fields[1].s
plit(","))); |
| 294 boolean isNegative = fields[2].equals("True"); | 290 boolean isNegative = fields[2].equals("True"); |
| 295 String[] arguments = new String[fields.length - 3]; | 291 String[] arguments = new String[fields.length - 3]; |
| 296 System.arraycopy(fields, 3, arguments, 0, arguments.length); | 292 System.arraycopy(fields, 3, arguments, 0, arguments.length); |
| 297 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume
nts); | 293 return new SharedTestCase(name, outcomes, isNegative, regularCompile, argume
nts); |
| 298 } | 294 } |
| 299 } | 295 } |
| OLD | NEW |