| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 import 'package:expect/expect.dart'; |
| 6 import 'memory_source_file_helper.dart'; |
| 7 |
| 8 import '../../../sdk/lib/_internal/compiler/compiler.dart' |
| 9 show Diagnostic; |
| 10 |
| 11 import 'dart:json'; |
| 12 |
| 13 main() { |
| 14 Uri script = currentDirectory.resolve(nativeToUriPath(new Options().script)); |
| 15 Uri libraryRoot = script.resolve('../../../sdk/'); |
| 16 Uri packageRoot = script.resolve('./packages/'); |
| 17 |
| 18 MemorySourceFileProvider.MEMORY_SOURCE_FILES = MEMORY_SOURCE_FILES; |
| 19 var provider = new MemorySourceFileProvider(); |
| 20 var diagnostics = []; |
| 21 void diagnosticHandler(Uri uri, int begin, int end, |
| 22 String message, Diagnostic kind) { |
| 23 if (kind == Diagnostic.VERBOSE_INFO) { |
| 24 return; |
| 25 } |
| 26 diagnostics.add('$uri:$begin:$end:$message:$kind'); |
| 27 } |
| 28 |
| 29 Compiler compiler = new Compiler(provider.readStringFromUri, |
| 30 (name, extension) => null, |
| 31 diagnosticHandler, |
| 32 libraryRoot, |
| 33 packageRoot, |
| 34 ['--analyze-only']); |
| 35 compiler.run(Uri.parse('memory:main.dart')); |
| 36 diagnostics.sort(); |
| 37 var expected = [ |
| 38 'memory:exporter.dart:43:47:Info: "function(hest)" is defined here.:info', |
| 39 'memory:library.dart:14:19:Info: "class(Fisk)" is (re)exported by ' |
| 40 'multiple libraries.:info', |
| 41 'memory:library.dart:30:34:Info: "function(fisk)" is (re)exported by ' |
| 42 'multiple libraries.:info', |
| 43 'memory:library.dart:41:45:Info: "function(hest)" is defined here.' |
| 44 ':info', |
| 45 'memory:main.dart:0:22:Info: "class(Fisk)" is imported here.:info', |
| 46 'memory:main.dart:0:22:Info: "function(fisk)" is imported here.:info', |
| 47 'memory:main.dart:0:22:Info: "function(hest)" is imported here.:info', |
| 48 'memory:main.dart:23:46:Info: "class(Fisk)" is imported here.:info', |
| 49 'memory:main.dart:23:46:Info: "function(fisk)" is imported here.:info', |
| 50 'memory:main.dart:23:46:Info: "function(hest)" is imported here.:info', |
| 51 'memory:main.dart:59:63:Warning: duplicate import of Fisk:warning', |
| 52 'memory:main.dart:76:80:duplicate import of fisk:error', |
| 53 'memory:main.dart:86:90:duplicate import of hest:error' |
| 54 ]; |
| 55 Expect.listEquals(expected, diagnostics); |
| 56 Expect.isTrue(compiler.compilationFailed); |
| 57 } |
| 58 |
| 59 const Map MEMORY_SOURCE_FILES = const { |
| 60 'main.dart': """ |
| 61 import 'library.dart'; |
| 62 import 'exporter.dart'; |
| 63 |
| 64 main() { |
| 65 Fisk x = null; |
| 66 fisk(); |
| 67 hest(); |
| 68 } |
| 69 """, |
| 70 'library.dart': """ |
| 71 library lib; |
| 72 |
| 73 class Fisk { |
| 74 } |
| 75 |
| 76 fisk() {} |
| 77 |
| 78 hest() {} |
| 79 """, |
| 80 'exporter.dart': """ |
| 81 library exporter; |
| 82 |
| 83 export 'library.dart'; |
| 84 |
| 85 hest() {} |
| 86 """, |
| 87 }; |
| OLD | NEW |