| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'package:expect/expect.dart'; | 5 import 'package:expect/expect.dart'; |
| 6 import 'memory_source_file_helper.dart'; | 6 import 'memory_source_file_helper.dart'; |
| 7 import "package:async_helper/async_helper.dart"; | 7 import "package:async_helper/async_helper.dart"; |
| 8 | 8 |
| 9 import 'package:compiler/compiler.dart' | 9 import 'package:compiler/compiler.dart' |
| 10 show Diagnostic; | 10 show Diagnostic; |
| 11 import 'package:compiler/src/commandline_options.dart'; |
| 11 import 'package:compiler/src/old_to_new_api.dart'; | 12 import 'package:compiler/src/old_to_new_api.dart'; |
| 12 | 13 |
| 13 main() { | 14 main() { |
| 14 Uri script = currentDirectory.resolveUri(Platform.script); | 15 Uri script = currentDirectory.resolveUri(Platform.script); |
| 15 Uri libraryRoot = script.resolve('../../../sdk/'); | 16 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 16 Uri packageRoot = script.resolve('./packages/'); | 17 Uri packageRoot = script.resolve('./packages/'); |
| 17 | 18 |
| 18 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); | 19 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); |
| 19 int warningCount = 0; | 20 int warningCount = 0; |
| 20 int errorCount = 0; | 21 int errorCount = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 throw 'unexpected diagnostic $kind: $message'; | 32 throw 'unexpected diagnostic $kind: $message'; |
| 32 } | 33 } |
| 33 } | 34 } |
| 34 | 35 |
| 35 Compiler compiler = new Compiler( | 36 Compiler compiler = new Compiler( |
| 36 new LegacyCompilerInput(provider.readStringFromUri), | 37 new LegacyCompilerInput(provider.readStringFromUri), |
| 37 new LegacyCompilerOutput(), | 38 new LegacyCompilerOutput(), |
| 38 new LegacyCompilerDiagnostics(diagnosticHandler), | 39 new LegacyCompilerDiagnostics(diagnosticHandler), |
| 39 libraryRoot, | 40 libraryRoot, |
| 40 packageRoot, | 41 packageRoot, |
| 41 ['--analyze-only'], | 42 [Flags.analyzeOnly], |
| 42 {}); | 43 {}); |
| 43 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { | 44 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 44 Expect.isTrue(compiler.compilationFailed); | 45 Expect.isTrue(compiler.compilationFailed); |
| 45 Expect.equals(5, errorCount); | 46 Expect.equals(5, errorCount); |
| 46 Expect.equals(1, warningCount); | 47 Expect.equals(1, warningCount); |
| 47 })); | 48 })); |
| 48 } | 49 } |
| 49 | 50 |
| 50 const Map MEMORY_SOURCE_FILES = const { | 51 const Map MEMORY_SOURCE_FILES = const { |
| 51 'main.dart': """ | 52 'main.dart': """ |
| 52 main() { | 53 main() { |
| 53 for (var x, y in []) { | 54 for (var x, y in []) { |
| 54 } | 55 } |
| 55 | 56 |
| 56 for (var x = 10 in []) { | 57 for (var x = 10 in []) { |
| 57 } | 58 } |
| 58 | 59 |
| 59 for (x.y in []) { // Also causes a warning "x unresolved". | 60 for (x.y in []) { // Also causes a warning "x unresolved". |
| 60 } | 61 } |
| 61 | 62 |
| 62 for ((){}() in []) { | 63 for ((){}() in []) { |
| 63 } | 64 } |
| 64 | 65 |
| 65 for (1 in []) { | 66 for (1 in []) { |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 """ | 69 """ |
| 69 }; | 70 }; |
| OLD | NEW |