| 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 "../../async_helper.dart"; |
| 6 import 'memory_source_file_helper.dart'; | 7 import 'memory_source_file_helper.dart'; |
| 7 | 8 |
| 8 import '../../../sdk/lib/_internal/compiler/compiler.dart' | 9 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 9 show Diagnostic; | 10 show Diagnostic; |
| 10 | 11 |
| 11 import 'dart:json'; | 12 import 'dart:json'; |
| 12 | 13 |
| 13 main() { | 14 main() { |
| 14 Uri script = currentDirectory.resolve(nativeToUriPath(Platform.script)); | 15 Uri script = currentDirectory.resolve(nativeToUriPath(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 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES; | 19 var provider = new MemorySourceFileProvider(MEMORY_SOURCE_FILES); |
| 19 var provider = new MemorySourceFileProvider(); | |
| 20 var diagnostics = []; | 20 var diagnostics = []; |
| 21 void diagnosticHandler(Uri uri, int begin, int end, | 21 void diagnosticHandler(Uri uri, int begin, int end, |
| 22 String message, Diagnostic kind) { | 22 String message, Diagnostic kind) { |
| 23 if (kind == Diagnostic.VERBOSE_INFO) { | 23 if (kind == Diagnostic.VERBOSE_INFO) { |
| 24 return; | 24 return; |
| 25 } | 25 } |
| 26 diagnostics.add('$uri:$begin:$end:$message:$kind'); | 26 diagnostics.add('$uri:$begin:$end:$message:$kind'); |
| 27 } | 27 } |
| 28 | 28 |
| 29 Compiler compiler = new Compiler(provider.readStringFromUri, | 29 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 30 (name, extension) => null, | 30 (name, extension) => null, |
| 31 diagnosticHandler, | 31 diagnosticHandler, |
| 32 libraryRoot, | 32 libraryRoot, |
| 33 packageRoot, | 33 packageRoot, |
| 34 ['--analyze-only']); | 34 ['--analyze-only']); |
| 35 compiler.run(Uri.parse('memory:main.dart')); | 35 asyncTest(() => compiler.run(Uri.parse('memory:main.dart')).then((_) { |
| 36 diagnostics.sort(); | 36 diagnostics.sort(); |
| 37 var expected = [ | 37 var expected = [ |
| 38 'memory:exporter.dart:43:47:Info: "function(hest)" is defined here.:info', | 38 'memory:exporter.dart:43:47:Info: "function(hest)" is defined here.' |
| 39 'memory:library.dart:14:19:Info: "class(Fisk)" is (re)exported by ' | 39 ':info', |
| 40 'multiple libraries.:info', | 40 'memory:library.dart:14:19:Info: "class(Fisk)" is (re)exported by ' |
| 41 'memory:library.dart:30:34:Info: "function(fisk)" is (re)exported by ' | 41 'multiple libraries.:info', |
| 42 'multiple libraries.:info', | 42 'memory:library.dart:30:34:Info: "function(fisk)" is (re)exported by ' |
| 43 'memory:library.dart:41:45:Info: "function(hest)" is defined here.' | 43 'multiple libraries.:info', |
| 44 ':info', | 44 'memory:library.dart:41:45:Info: "function(hest)" is defined here.' |
| 45 'memory:main.dart:0:22:Info: "class(Fisk)" is imported here.:info', | 45 ':info', |
| 46 'memory:main.dart:0:22:Info: "function(fisk)" is imported here.:info', | 46 'memory:main.dart:0:22:Info: "class(Fisk)" is imported here.:info', |
| 47 'memory:main.dart:0:22:Info: "function(hest)" is imported here.:info', | 47 'memory:main.dart:0:22:Info: "function(fisk)" is imported here.:info', |
| 48 'memory:main.dart:23:46:Info: "class(Fisk)" is imported here.:info', | 48 'memory:main.dart:0:22:Info: "function(hest)" is imported here.:info', |
| 49 'memory:main.dart:23:46:Info: "function(fisk)" is imported here.:info', | 49 'memory:main.dart:23:46:Info: "class(Fisk)" is imported here.:info', |
| 50 'memory:main.dart:23:46:Info: "function(hest)" is imported here.:info', | 50 'memory:main.dart:23:46:Info: "function(fisk)" is imported here.:info', |
| 51 'memory:main.dart:59:63:Warning: Duplicate import of "Fisk".:warning', | 51 'memory:main.dart:23:46:Info: "function(hest)" is imported here.:info', |
| 52 'memory:main.dart:76:80:Error: Duplicate import of "fisk".:error', | 52 'memory:main.dart:59:63:Warning: Duplicate import of "Fisk".:warning', |
| 53 'memory:main.dart:86:90:Error: Duplicate import of "hest".:error' | 53 'memory:main.dart:76:80:Error: Duplicate import of "fisk".:error', |
| 54 ]; | 54 'memory:main.dart:86:90:Error: Duplicate import of "hest".:error' |
| 55 Expect.listEquals(expected, diagnostics); | 55 ]; |
| 56 Expect.isTrue(compiler.compilationFailed); | 56 Expect.listEquals(expected, diagnostics); |
| 57 Expect.isTrue(compiler.compilationFailed); |
| 58 })); |
| 57 } | 59 } |
| 58 | 60 |
| 59 const Map MEMORY_SOURCE_FILES = const { | 61 const Map MEMORY_SOURCE_FILES = const { |
| 60 'main.dart': """ | 62 'main.dart': """ |
| 61 import 'library.dart'; | 63 import 'library.dart'; |
| 62 import 'exporter.dart'; | 64 import 'exporter.dart'; |
| 63 | 65 |
| 64 main() { | 66 main() { |
| 65 Fisk x = null; | 67 Fisk x = null; |
| 66 fisk(); | 68 fisk(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 hest() {} | 80 hest() {} |
| 79 """, | 81 """, |
| 80 'exporter.dart': """ | 82 'exporter.dart': """ |
| 81 library exporter; | 83 library exporter; |
| 82 | 84 |
| 83 export 'library.dart'; | 85 export 'library.dart'; |
| 84 | 86 |
| 85 hest() {} | 87 hest() {} |
| 86 """, | 88 """, |
| 87 }; | 89 }; |
| OLD | NEW |