Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: tests/compiler/dart2js/warnings_checker.dart

Issue 2788373002: Add Source.getTextLine and use it to display source snippets in error messages. (Closed)
Patch Set: dartfmt Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW
« pkg/kernel/lib/ast.dart ('K') | « tests/compiler/dart2js/sourcemaps/sourcemap_html_helper.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698