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

Unified Diff: tests/compiler/dart2js/sourcemaps/load_save_test.dart

Issue 2431223006: Add stacktrace_test (Closed)
Patch Set: Updated cf. comments. Created 4 years, 1 month 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 | « tests/compiler/dart2js/sourcemaps/load.dart ('k') | tests/compiler/dart2js/sourcemaps/save.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/compiler/dart2js/sourcemaps/load_save_test.dart
diff --git a/tests/compiler/dart2js/sourcemaps/load_save_test.dart b/tests/compiler/dart2js/sourcemaps/load_save_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..380f7f28e38b50502f2014741b99e1e691b51fec
--- /dev/null
+++ b/tests/compiler/dart2js/sourcemaps/load_save_test.dart
@@ -0,0 +1,76 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:convert';
+import 'package:source_maps/source_maps.dart';
+import 'package:unittest/unittest.dart';
+import 'load.dart';
+import 'save.dart';
+
+const String SOURCEMAP = '''
+{
+ "version": 3,
+ "file": "out.js",
+ "sourceRoot": "",
+ "sources": ["sdk/lib/_internal/compiler/js_lib/js_primitives.dart","hello_world.dart","sdk/lib/_internal/compiler/js_lib/internal_patch.dart"],
+ "names": ["printString","main","printToConsole"],
+ "mappings": "A;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;;eAoBAA;;;AAIIA;;;;AAOAA;;;AAKAA;;;AAMAA;;;GAOJA;;sC;;QC5CAC;;ICYEC;GDRFD;;;;A;A;A;;;A;;;A;A;A;A;A;A;A;;;;;;A;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;A;C;;;;;;;;;;;;;;;;;;;;;;;;;;;;A"
+}''';
+
+const String HUMAN_READABLE_SOURCE_MAP = '''
+{
+ "file": "out.js",
+ "sourceRoot": "",
+ "sources": {
+ "0": "out.js.map",
+ "1": "test.dart",
+ "2": "out.js"
+ },
+ "lines": [
+ {"target": "3,3-", "source": "1:2,17"},
+ {"target": "4,3-", "source": "1:3,17"},
+ {"target": "5,3-15", "source": "1:4,17"},
+ {"target": "5,15-20", "source": "1:5,17"},
+ {"target": "5,20-", "source": "1:6,4"},
+ {"target": "6,3-", "source": "1:7,17"},
+ {"target": "7,3-", "source": "1:8,17"},
+ {"target": "8,1-", "source": "1:9,1"},
+ {"target": "10,3-", "source": "1:11,17"},
+ {"target": "11,3-", "source": "1:12,17"},
+ {"target": "12,3-", "source": "1:13,17"},
+ {"target": "13,3-", "source": "1:14,17"},
+ {"target": "14,1-", "source": "1:15,4"}
+ ]
+}''';
+
+void main() {
+ test('read/write', () {
+ SingleMapping sourceMap =
+ new SingleMapping.fromJson(JSON.decode(SOURCEMAP));
+ String humanReadable = convertToHumanReadableSourceMap(sourceMap);
+ SingleMapping sourceMap2 = convertFromHumanReadableSourceMap(humanReadable);
+ String humanReadable2 = convertToHumanReadableSourceMap(sourceMap2);
+ SingleMapping sourceMap3 =
+ convertFromHumanReadableSourceMap(humanReadable2);
+ String humanReadable3 = convertToHumanReadableSourceMap(sourceMap3);
+
+ // Target line entries without sourceUrl are removed.
+ //expect(sourceMap.toJson(), equals(sourceMap2.toJson()));
+ expect(sourceMap2.toJson(), equals(sourceMap3.toJson()));
+ expect(JSON.decode(humanReadable), equals(JSON.decode(humanReadable2)));
+ expect(JSON.decode(humanReadable2), equals(JSON.decode(humanReadable3)));
+ });
+
+ test('write/read', () {
+ SingleMapping sourceMap =
+ convertFromHumanReadableSourceMap(HUMAN_READABLE_SOURCE_MAP);
+ print(sourceMap);
+ String humanReadable = convertToHumanReadableSourceMap(sourceMap);
+ print(humanReadable);
+ SingleMapping sourceMap2 = convertFromHumanReadableSourceMap(humanReadable);
+ expect(JSON.decode(HUMAN_READABLE_SOURCE_MAP),
+ equals(JSON.decode(humanReadable)));
+ expect(sourceMap.toJson(), equals(sourceMap2.toJson()));
+ });
+}
« no previous file with comments | « tests/compiler/dart2js/sourcemaps/load.dart ('k') | tests/compiler/dart2js/sourcemaps/save.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698