Skip to content

Commit

Permalink
support **= (#4778)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlamsl committed Mar 15, 2021
1 parent 149d75c commit 01aa078
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/parse.js
Expand Up @@ -100,6 +100,7 @@ var OPERATORS = makePredicate([
"/=",
"*=",
"%=",
"**=",
">>=",
"<<=",
">>>=",
Expand Down Expand Up @@ -652,7 +653,7 @@ var UNARY_PREFIX = makePredicate("typeof void delete -- ++ ! ~ - +");

var UNARY_POSTFIX = makePredicate("-- ++");

var ASSIGNMENT = makePredicate("= += -= /= *= %= >>= <<= >>>= |= ^= &=");
var ASSIGNMENT = makePredicate("= += -= /= *= %= **= >>= <<= >>>= |= ^= &=");

var PRECEDENCE = function(a, ret) {
for (var i = 0; i < a.length;) {
Expand Down
22 changes: 22 additions & 0 deletions test/compress/exponentiation.js
Expand Up @@ -43,6 +43,28 @@ await: {
node_version: ">=8"
}

assignment_1: {
input: {
var a = 2;
a **= 5;
console.log(a);
}
expect_exact: "var a=2;a**=5;console.log(a);"
expect_stdout: "32"
node_version: ">=8"
}

assignment_2: {
input: {
var a = 8n;
a **= a;
console.log(a);
}
expect_exact: "var a=8n;a**=a;console.log(a);"
expect_stdout: "16777216n"
node_version: ">=10"
}

evaluate: {
options = {
evaluate: true,
Expand Down
3 changes: 2 additions & 1 deletion test/ufuzz/index.js
Expand Up @@ -277,14 +277,15 @@ var ASSIGNMENTS = [
"-=",
"*=",
"/=",
"%=",
"&=",
"|=",
"^=",
"<<=",
">>=",
">>>=",
"%=",
];
if (SUPPORT.exponentiation) ASSIGNMENTS.push("**=");

var UNARY_SAFE = [
"+",
Expand Down

0 comments on commit 01aa078

Please sign in to comment.