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

Unified Diff: tests/compiler/dart2js/source_map_validator_helper.dart

Issue 232943003: Add index consistency check to source map validation tests. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/source_map_validator_helper.dart
diff --git a/tests/compiler/dart2js/source_map_validator_helper.dart b/tests/compiler/dart2js/source_map_validator_helper.dart
index 934a63c5a219c5b0293884a86640ea7ce211a299..afebda0853ce628e0c3958e744f3e20358b4eefa 100644
--- a/tests/compiler/dart2js/source_map_validator_helper.dart
+++ b/tests/compiler/dart2js/source_map_validator_helper.dart
@@ -14,9 +14,41 @@ validateSourceMap(Uri targetUri) {
Uri mapUri = getMapUri(targetUri);
SingleMapping sourceMap = getSourceMap(mapUri);
checkFileReferences(targetUri, mapUri, sourceMap);
+ checkIndexReferences(targetUri, mapUri, sourceMap);
checkRedundancy(sourceMap);
}
+checkIndexReferences(Uri targetUri, Uri mapUri, SingleMapping sourceMap) {
+ List<String> target =
+ new File.fromUri(targetUri).readAsStringSync().split('\n');
+ int urlsLength = sourceMap.urls.length;
+ List<List<String>> sources = new List(urlsLength);
+ print('Reading sources');
+ for (int i = 0; i < urlsLength; i++) {
+ sources[i] = new File.fromUri(mapUri.resolve(sourceMap.urls[i])).
+ readAsStringSync().split('\n');
+ }
+
+ sourceMap.lines.forEach((TargetLineEntry line) {
+ Expect.isTrue(line.line < target.length);
Johnni Winther 2014/04/10 12:55:01 Check that line.line >= 1 (or is it 0?)
zarah 2014/04/10 13:46:19 Done.
+ for (TargetEntry entry in line.entries) {
+ int urlIndex = entry.sourceUrlId;
+
+ // TODO(zarah): Entry columns sometimes point one or more characters too
+ // far. Incomment this check when this is fixed.
+ //
+ // Expect.isTrue(entry.column < target[line.line].length);
Johnni Winther 2014/04/10 12:55:01 Check entry.column >= 1 (or 0?)
zarah 2014/04/10 13:46:19 Done.
+ Expect.isTrue(urlIndex == null || urlIndex < urlsLength);
Johnni Winther 2014/04/10 12:55:01 Check urlIndex >= 0.
zarah 2014/04/10 13:46:19 Done.
+ Expect.isTrue(entry.sourceLine == null ||
+ entry.sourceLine < sources[urlIndex].length);
Johnni Winther 2014/04/10 12:55:01 Check entry.sourceLine >= 1 (or 1?).
zarah 2014/04/10 13:46:19 Done.
+ Expect.isTrue(entry.sourceColumn == null ||
+ entry.sourceColumn < sources[urlIndex][entry.sourceLine].length);
Johnni Winther 2014/04/10 12:55:01 Ditto.
zarah 2014/04/10 13:46:19 Done.
+ Expect.isTrue(entry.sourceNameId == null ||
+ entry.sourceNameId < sourceMap.names.length);
Johnni Winther 2014/04/10 12:55:01 Ditto.
zarah 2014/04/10 13:46:19 Done.
+ }
+ });
+}
+
checkFileReferences(Uri targetUri, Uri mapUri, SingleMapping sourceMap) {
Expect.equals(targetUri, mapUri.resolve(sourceMap.targetUrl));
print('Checking sources');
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698