--- /dev/null
+var Mocha = require('mocha'),
+ fs = require('fs'),
+ path = require('path');
+
+// Instantiate a Mocha instance.
+var mocha = new Mocha({});
+
+var testDir = __dirname + '/mocha/';
+
+// Add each .js file to the mocha instance
+fs.readdirSync(testDir).filter(function(file){
+ // Only keep the .js files
+ return file.substr(-3) === '.js';
+
+}).forEach(function(file){
+ mocha.addFile(
+ path.join(testDir, file)
+ );
+});
+
+module.exports = function() {
+ mocha.run(function(failures) {
+ if (failures !== 0) {
+ process.on('exit', function () {
+ process.exit(failures);
+ });
+ }
+ });
+};
\ No newline at end of file
--- /dev/null
+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