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 // Test that dart2js produces the expected static type warnings to ensures that | 5 // Test that dart2js produces the expected static type warnings to ensures that |
6 // the analyzer and dart2js agrees on the tests. | 6 // the analyzer and dart2js agrees on the tests. |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 import 'package:expect/expect.dart'; | 10 import 'package:expect/expect.dart'; |
11 import 'package:async_helper/async_helper.dart'; | 11 import 'package:async_helper/async_helper.dart'; |
12 import 'memory_compiler.dart'; | 12 import 'memory_compiler.dart'; |
| 13 import 'package:compiler/src/commandline_options.dart'; |
13 import 'package:compiler/src/filenames.dart'; | 14 import 'package:compiler/src/filenames.dart'; |
14 import 'package:compiler/src/io/source_file.dart'; | 15 import 'package:compiler/src/io/source_file.dart'; |
15 import 'package:compiler/src/source_file_provider.dart'; | 16 import 'package:compiler/src/source_file_provider.dart'; |
16 import 'package:compiler/src/util/uri_extras.dart'; | 17 import 'package:compiler/src/util/uri_extras.dart'; |
17 import 'dart:convert'; | 18 import 'dart:convert'; |
18 | 19 |
19 void checkWarnings(Map<String, dynamic> tests, [List<String> arguments]) { | 20 void checkWarnings(Map<String, dynamic> tests, [List<String> arguments]) { |
20 bool isWindows = Platform.isWindows; | 21 bool isWindows = Platform.isWindows; |
21 Uri script = currentDirectory.resolveUri(Platform.script); | 22 Uri script = currentDirectory.resolveUri(Platform.script); |
22 bool warningsMismatch = false; | 23 bool warningsMismatch = false; |
(...skipping 11 matching lines...) Expand all Loading... |
34 line.contains('static warning'))) { | 35 line.contains('static warning'))) { |
35 expectedWarnings[lineNo] = line; | 36 expectedWarnings[lineNo] = line; |
36 } | 37 } |
37 lineNo++; | 38 lineNo++; |
38 } | 39 } |
39 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); | 40 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); |
40 DiagnosticCollector collector = new DiagnosticCollector(); | 41 DiagnosticCollector collector = new DiagnosticCollector(); |
41 await runCompiler( | 42 await runCompiler( |
42 entryPoint: uri, | 43 entryPoint: uri, |
43 diagnosticHandler: collector, | 44 diagnosticHandler: collector, |
44 options: ['--analyze-only'], | 45 options: [Flags.analyzeOnly], |
45 showDiagnostics: verbose); | 46 showDiagnostics: verbose); |
46 Map<String, List<int>> statusMap = tests[test]; | 47 Map<String, List<int>> statusMap = tests[test]; |
47 // Line numbers with known unexpected warnings. | 48 // Line numbers with known unexpected warnings. |
48 List<int> unexpectedStatus = []; | 49 List<int> unexpectedStatus = []; |
49 if (statusMap != null && statusMap.containsKey('unexpected')) { | 50 if (statusMap != null && statusMap.containsKey('unexpected')) { |
50 unexpectedStatus = statusMap['unexpected']; | 51 unexpectedStatus = statusMap['unexpected']; |
51 } | 52 } |
52 // Line numbers with known missing warnings. | 53 // Line numbers with known missing warnings. |
53 List<int> missingStatus = []; | 54 List<int> missingStatus = []; |
54 if (statusMap != null && statusMap.containsKey('missing')) { | 55 if (statusMap != null && statusMap.containsKey('missing')) { |
(...skipping 18 matching lines...) Expand all Loading... |
73 String line = expectedWarnings[lineNo]; | 74 String line = expectedWarnings[lineNo]; |
74 print('$uri [${lineNo+1}]: Missing static type warning.'); | 75 print('$uri [${lineNo+1}]: Missing static type warning.'); |
75 print(line); | 76 print(line); |
76 } | 77 } |
77 } | 78 } |
78 } | 79 } |
79 }).then((_) { | 80 }).then((_) { |
80 Expect.isFalse(warningsMismatch); | 81 Expect.isFalse(warningsMismatch); |
81 })); | 82 })); |
82 } | 83 } |
OLD | NEW |