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