Add exponentiation operator

This commit is contained in:
Anthony Van de Gejuchte
2016-06-18 00:25:18 +02:00
committed by Richard van Velzen
parent 2246c79318
commit 6eaeb19a4a
6 changed files with 190 additions and 4 deletions

32
test/mocha/expression.js Normal file
View File

@@ -0,0 +1,32 @@
var assert = require("assert");
var uglify = require("../../");
describe("Expression", function() {
it("Should not allow the first exponentiation operator to be prefixed with an unary operator", function() {
var tests = [
"+5 ** 3",
"-5 ** 3",
"~5 ** 3",
"!5 ** 3",
"void 5 ** 3",
"typeof 5 ** 3",
"delete 5 ** 3",
"var a = -(5) ** 3;"
];
var fail = function(e) {
return e instanceof uglify.JS_Parse_Error &&
/^SyntaxError: Unexpected token: operator \((?:[!+~-]|void|typeof|delete)\)/.test(e.message);
}
var exec = function(test) {
return function() {
uglify.parse(test);
}
}
for (var i = 0; i < tests.length; i++) {
assert.throws(exec(tests[i]), fail, tests[i]);
}
});
});