aboutsummaryrefslogtreecommitdiff
path: root/test/mocha/string-literal.js
diff options
context:
space:
mode:
authorAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2015-12-27 22:28:03 +0100
committerAnthony Van de Gejuchte <anthonyvdgent@gmail.com>2015-12-27 22:38:20 +0100
commit8c6af09ae014eb2370349fb7b419ee912abac64f (patch)
treeca716f8b5942af27a1487406dc1c5cbb872927b5 /test/mocha/string-literal.js
parent6f3e35bb3f04303e6b7cc74cfc25bfee3c792a98 (diff)
downloadtracifyjs-8c6af09ae014eb2370349fb7b419ee912abac64f.tar.gz
tracifyjs-8c6af09ae014eb2370349fb7b419ee912abac64f.zip
Add mocha tests
Diffstat (limited to 'test/mocha/string-literal.js')
-rw-r--r--test/mocha/string-literal.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/mocha/string-literal.js b/test/mocha/string-literal.js
new file mode 100644
index 00000000..64933632
--- /dev/null
+++ b/test/mocha/string-literal.js
@@ -0,0 +1,29 @@
+var UglifyJS = require('../../');
+var assert = require("assert");
+
+describe("String literals", function() {
+ it("Should throw syntax error if a string literal contains a newline", function() {
+ var inputs = [
+ "'\n'",
+ "'\r'",
+ '"\r\n"',
+ "'\u2028'",
+ '"\u2029"'
+ ];
+
+ var test = function(input) {
+ return function() {
+ var ast = UglifyJS.parse(input);
+ }
+ };
+
+ var error = function(e) {
+ return e instanceof UglifyJS.JS_Parse_Error &&
+ e.message === "Unterminated string constant"
+ };
+
+ for (var input in inputs) {
+ assert.throws(test(inputs[input]), error);
+ }
+ });
+}); \ No newline at end of file