| 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'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 bool warningsMismatch = false; | 22 bool warningsMismatch = false; |
| 23 bool verbose = arguments != null && arguments.contains('-v'); | 23 bool verbose = arguments != null && arguments.contains('-v'); |
| 24 asyncTest(() => Future.forEach(tests.keys, (String test) { | 24 asyncTest(() => Future.forEach(tests.keys, (String test) { |
| 25 Uri uri = script.resolve('../../$test'); | 25 Uri uri = script.resolve('../../$test'); |
| 26 String source = UTF8.decode(readAll(uriPathToNative(uri.path))); | 26 String source = UTF8.decode(readAll(uriPathToNative(uri.path))); |
| 27 SourceFile file = new StringSourceFile( | 27 SourceFile file = new StringSourceFile( |
| 28 relativize(currentDirectory, uri, isWindows), source); | 28 relativize(currentDirectory, uri, isWindows), source); |
| 29 Map<int,String> expectedWarnings = {}; | 29 Map<int,String> expectedWarnings = {}; |
| 30 int lineNo = 0; | 30 int lineNo = 0; |
| 31 for (String line in source.split('\n')) { | 31 for (String line in source.split('\n')) { |
| 32 if (line.contains('///') && line.contains('static type warning')) { | 32 if (line.contains('///') && |
| 33 (line.contains('static type warning') || |
| 34 line.contains('static warning'))) { |
| 33 expectedWarnings[lineNo] = line; | 35 expectedWarnings[lineNo] = line; |
| 34 } | 36 } |
| 35 lineNo++; | 37 lineNo++; |
| 36 } | 38 } |
| 37 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); | 39 Set<int> unseenWarnings = new Set<int>.from(expectedWarnings.keys); |
| 38 DiagnosticCollector collector = new DiagnosticCollector(); | 40 DiagnosticCollector collector = new DiagnosticCollector(); |
| 39 var compiler = compilerFor(const {}, | 41 var compiler = compilerFor(const {}, |
| 40 diagnosticHandler: collector, | 42 diagnosticHandler: collector, |
| 41 options: ['--analyze-only'], | 43 options: ['--analyze-only'], |
| 42 showDiagnostics: verbose); | 44 showDiagnostics: verbose); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 72 print('$uri [${lineNo+1}]: Missing static type warning.'); | 74 print('$uri [${lineNo+1}]: Missing static type warning.'); |
| 73 print(line); | 75 print(line); |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 } | 78 } |
| 77 }); | 79 }); |
| 78 }).then((_) { | 80 }).then((_) { |
| 79 Expect.isFalse(warningsMismatch); | 81 Expect.isFalse(warningsMismatch); |
| 80 })); | 82 })); |
| 81 } | 83 } |
| OLD | NEW |