aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/line-endings.js
diff options
context:
space:
mode:
authorkzc <zaxxon2011@gmail.com>2016-04-25 00:42:18 -0400
committerRichard van Velzen <rvanvelzen@experty.com>2016-05-04 20:02:29 +0200
commitf39fd3d58384d9bafbd18d3c1ec927940eeba458 (patch)
tree9fce3733db15d020f9d5dfe5323930327a06f1e1 /test/mocha/line-endings.js
parent65887d9a56d8f3eb1e75cd924b4fd2c9065d0e11 (diff)
downloadtracifyjs-f39fd3d58384d9bafbd18d3c1ec927940eeba458.tar.gz
tracifyjs-f39fd3d58384d9bafbd18d3c1ec927940eeba458.zip
Handle CR line endings in comments.
Fixes #1050
Diffstat (limited to 'test/mocha/line-endings.js')
-rw-r--r--test/mocha/line-endings.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/mocha/line-endings.js b/test/mocha/line-endings.js
new file mode 100644
index 00000000..8fd56a19
--- /dev/null
+++ b/test/mocha/line-endings.js
@@ -0,0 +1,34 @@
+var Uglify = require('../../');
+var assert = require("assert");
+
+describe("line-endings", function() {
+ var options = {
+ fromString: true,
+ mangle: false,
+ compress: false,
+ output: {
+ beautify: false,
+ comments: /^!/,
+ }
+ };
+ var expected_code = '/*!one\n2\n3*/\nfunction f(x){if(x)return 3}';
+
+ it("Should parse LF line endings", function() {
+ var js = '/*!one\n2\n3*///comment\nfunction f(x) {\n if (x)\n//comment\n return 3;\n}\n';
+ var result = Uglify.minify(js, options);
+ assert.strictEqual(result.code, expected_code);
+ });
+
+ it("Should parse CR/LF line endings", function() {
+ var js = '/*!one\r\n2\r\n3*///comment\r\nfunction f(x) {\r\n if (x)\r\n//comment\r\n return 3;\r\n}\r\n';
+ var result = Uglify.minify(js, options);
+ assert.strictEqual(result.code, expected_code);
+ });
+
+ it("Should parse CR line endings", function() {
+ var js = '/*!one\r2\r3*///comment\rfunction f(x) {\r if (x)\r//comment\r return 3;\r}\r';
+ var result = Uglify.minify(js, options);
+ assert.strictEqual(result.code, expected_code);
+ });
+});
+