| 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 // Line numbers with known unexpected warnings. | 48 // Line numbers with known unexpected warnings. |
| 49 List<int> unexpectedStatus = []; | 49 List<int> unexpectedStatus = []; |
| 50 if (statusMap != null && statusMap.containsKey('unexpected')) { | 50 if (statusMap != null && statusMap.containsKey('unexpected')) { |
| 51 unexpectedStatus = statusMap['unexpected']; | 51 unexpectedStatus = statusMap['unexpected']; |
| 52 } | 52 } |
| 53 // Line numbers with known missing warnings. | 53 // Line numbers with known missing warnings. |
| 54 List<int> missingStatus = []; | 54 List<int> missingStatus = []; |
| 55 if (statusMap != null && statusMap.containsKey('missing')) { | 55 if (statusMap != null && statusMap.containsKey('missing')) { |
| 56 missingStatus = statusMap['missing']; | 56 missingStatus = statusMap['missing']; |
| 57 } | 57 } |
| 58 for (DiagnosticMessage message in collector.warnings) { | 58 for (CollectedMessage message in collector.warnings) { |
| 59 Expect.equals(uri, message.uri); | 59 Expect.equals(uri, message.uri); |
| 60 int lineNo = file.getLine(message.begin); | 60 int lineNo = file.getLine(message.begin); |
| 61 if (expectedWarnings.containsKey(lineNo)) { | 61 if (expectedWarnings.containsKey(lineNo)) { |
| 62 unseenWarnings.remove(lineNo); | 62 unseenWarnings.remove(lineNo); |
| 63 } else if (!unexpectedStatus.contains(lineNo+1)) { | 63 } else if (!unexpectedStatus.contains(lineNo+1)) { |
| 64 warningsMismatch = true; | 64 warningsMismatch = true; |
| 65 print(file.getLocationMessage( | 65 print(file.getLocationMessage( |
| 66 'Unexpected warning: ${message.message}', | 66 'Unexpected warning: ${message.message}', |
| 67 message.begin, message.end)); | 67 message.begin, message.end)); |
| 68 } | 68 } |
| 69 } | 69 } |
| 70 if (!unseenWarnings.isEmpty) { | 70 if (!unseenWarnings.isEmpty) { |
| 71 for (int lineNo in unseenWarnings) { | 71 for (int lineNo in unseenWarnings) { |
| 72 if (!missingStatus.contains(lineNo+1)) { | 72 if (!missingStatus.contains(lineNo+1)) { |
| 73 warningsMismatch = true; | 73 warningsMismatch = true; |
| 74 String line = expectedWarnings[lineNo]; | 74 String line = expectedWarnings[lineNo]; |
| 75 print('$uri [${lineNo+1}]: Missing static type warning.'); | 75 print('$uri [${lineNo+1}]: Missing static type warning.'); |
| 76 print(line); | 76 print(line); |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 }).then((_) { | 80 }).then((_) { |
| 81 Expect.isFalse(warningsMismatch); | 81 Expect.isFalse(warningsMismatch); |
| 82 })); | 82 })); |
| 83 } | 83 } |
| OLD | NEW |