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

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: Changed indentation. 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..988c60c034e832e3e3244ad41d387df9f5af9eb4 100644
--- a/tests/compiler/dart2js/source_map_validator_helper.dart
+++ b/tests/compiler/dart2js/source_map_validator_helper.dart
@@ -14,9 +14,47 @@ 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 >= 0);
+ Expect.isTrue(line.line < target.length);
+ 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);
+ Expect.isTrue(entry.column >= 0);
+ Expect.isTrue(urlIndex == null ||
+ (urlIndex >= 0 && urlIndex < urlsLength));
+ Expect.isTrue(entry.sourceLine == null ||
+ (entry.sourceLine >= 0 &&
+ entry.sourceLine < sources[urlIndex].length));
+ Expect.isTrue(entry.sourceColumn == null ||
+ (entry.sourceColumn >= 0 &&
+ entry.sourceColumn < sources[urlIndex][entry.sourceLine].length));
+ Expect.isTrue(entry.sourceNameId == null ||
+ (entry.sourceNameId >= 0 &&
+ entry.sourceNameId < sourceMap.names.length));
+ }
+ });
+}
+
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