Chromium Code Reviews| 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." | |
|
Johnni Winther
2013/06/06 12:28:31
Use ' instead of " to avoid \"
ahe
2013/06/06 13:56:16
Done.
| |
| 39 ":info", | |
| 40 "memory:library.dart:14:19:Info: \"class(Fisk)\" is (re)exported by " | |
| 41 "multiple libraries.:info", | |
| 42 "memory:library.dart:30:34:Info: \"function(fisk)\" is (re)exported by " | |
| 43 "multiple libraries.:info", | |
| 44 "memory:library.dart:41:45:Info: \"function(hest)\" is defined here." | |
| 45 ":info", | |
| 46 "memory:main.dart:0:22:Info: \"class(Fisk)\" is imported here.:info", | |
| 47 "memory:main.dart:0:22:Info: \"function(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: \"class(Fisk)\" is imported here.:info", | |
| 50 "memory:main.dart:23:46:Info: \"function(fisk)\" is imported here.:info", | |
| 51 "memory:main.dart:23:46:Info: \"function(hest)\" is imported here.:info", | |
| 52 "memory:main.dart:59:63:Warning: duplicate import of Fisk:warning", | |
| 53 "memory:main.dart:76:80:duplicate import of fisk:error", | |
| 54 "memory:main.dart:86:90:duplicate import of hest:error" | |
| 55 ]; | |
| 56 Expect.listEquals(expected, diagnostics); | |
| 57 Expect.isTrue(compiler.compilationFailed); | |
| 58 } | |
| 59 | |
| 60 const Map MEMORY_SOURCE_FILES = const { | |
| 61 'main.dart': """ | |
| 62 import 'library.dart'; | |
| 63 import 'exporter.dart'; | |
| 64 | |
| 65 main() { | |
| 66 Fisk x = null; | |
| 67 fisk(); | |
| 68 hest(); | |
| 69 } | |
| 70 """, | |
| 71 'library.dart': """ | |
| 72 library lib; | |
| 73 | |
| 74 class Fisk { | |
| 75 } | |
| 76 | |
| 77 fisk() {} | |
| 78 | |
| 79 hest() {} | |
| 80 """, | |
| 81 'exporter.dart': """ | |
| 82 library exporter; | |
| 83 | |
| 84 export 'library.dart'; | |
| 85 | |
| 86 hest() {} | |
| 87 """, | |
| 88 }; | |
| OLD | NEW |