aboutsummaryrefslogtreecommitdiff
path: root/test/sourcemaps.js
diff options
context:
space:
mode:
authorFábio Santos <fabiosantosart@gmail.com>2015-10-20 19:48:56 +0100
committerFábio Santos <fabiosantosart@gmail.com>2015-10-20 19:48:56 +0100
commitb5623b19d499748d0b1cf97204180f9d4d2fc4a1 (patch)
treed38ac41a03d5b340d5efb6190e571dfc4c8f937e /test/sourcemaps.js
parent6b2861e0861968f1f7acae5cf964cc0e6244b0be (diff)
downloadtracifyjs-b5623b19d499748d0b1cf97204180f9d4d2fc4a1.tar.gz
tracifyjs-b5623b19d499748d0b1cf97204180f9d4d2fc4a1.zip
Fix #836
Diffstat (limited to 'test/sourcemaps.js')
-rw-r--r--test/sourcemaps.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/sourcemaps.js b/test/sourcemaps.js
new file mode 100644
index 00000000..7db4672e
--- /dev/null
+++ b/test/sourcemaps.js
@@ -0,0 +1,40 @@
+var UglifyJS = require("..");
+var ok = require("assert");
+
+module.exports = function () {
+ console.log("--- Sourcemaps tests");
+
+ var basic = source_map([
+ 'var x = 1 + 1;'
+ ].join('\n'));
+
+ ok.equal(basic.version, 3);
+ ok.deepEqual(basic.names, ['x']);
+
+ var issue836 = source_map([
+ "({",
+ " get enabled() {",
+ " return 3;",
+ " },",
+ " set enabled(x) {",
+ " ;",
+ " }",
+ "});",
+ ].join("\n"));
+
+ ok.deepEqual(issue836.names, ['enabled', 'x']);
+}
+
+function source_map(js) {
+ var source_map = UglifyJS.SourceMap();
+ var stream = UglifyJS.OutputStream({ source_map: source_map });
+ var parsed = UglifyJS.parse(js);
+ parsed.print(stream);
+ return JSON.parse(source_map.toString());
+}
+
+// Run standalone
+if (module.parent === null) {
+ module.exports();
+}
+