aboutsummaryrefslogtreecommitdiff
path: root/test/ufuzz/index.js
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-06-07 22:23:23 +0100
committerGitHub <noreply@github.com>2020-06-08 05:23:23 +0800
commitdf3bb8028a7cd8a69a3c76090d12f808ca7abc3b (patch)
tree210770477d209324562885e6777d3d150ce27035 /test/ufuzz/index.js
parent28b7b15da19a2a081ab768f8315ce39db7c52b63 (diff)
downloadtracifyjs-df3bb8028a7cd8a69a3c76090d12f808ca7abc3b.tar.gz
tracifyjs-df3bb8028a7cd8a69a3c76090d12f808ca7abc3b.zip
fix corner cases related to `in` (#3964)
Diffstat (limited to 'test/ufuzz/index.js')
-rw-r--r--test/ufuzz/index.js24
1 files changed, 16 insertions, 8 deletions
diff --git a/test/ufuzz/index.js b/test/ufuzz/index.js
index edd2ab80..eec4ab4a 100644
--- a/test/ufuzz/index.js
+++ b/test/ufuzz/index.js
@@ -168,7 +168,7 @@ var VALUES = [
"this",
];
-var BINARY_OPS_NO_COMMA = [
+var BINARY_OPS = [
" + ", // spaces needed to disambiguate with ++ cases (could otherwise cause syntax errors)
" - ",
"/",
@@ -190,9 +190,14 @@ var BINARY_OPS_NO_COMMA = [
"%",
"&&",
"||",
- "^" ];
-
-var BINARY_OPS = [","].concat(BINARY_OPS_NO_COMMA);
+ "^",
+ ",",
+];
+BINARY_OPS = BINARY_OPS.concat(BINARY_OPS);
+BINARY_OPS = BINARY_OPS.concat(BINARY_OPS);
+BINARY_OPS = BINARY_OPS.concat(BINARY_OPS);
+BINARY_OPS = BINARY_OPS.concat(BINARY_OPS);
+BINARY_OPS.push(" in ");
var ASSIGNMENTS = [
"=",
@@ -879,7 +884,7 @@ function createNestedBinaryExpr(recurmax, noComma, stmtDepth, canThrow) {
}
function _createBinaryExpr(recurmax, noComma, stmtDepth, canThrow) {
return "(" + _createSimpleBinaryExpr(recurmax, noComma, stmtDepth, canThrow)
- + createBinaryOp(noComma) + _createSimpleBinaryExpr(recurmax, noComma, stmtDepth, canThrow) + ")";
+ + createBinaryOp(noComma, canThrow) + _createSimpleBinaryExpr(recurmax, noComma, stmtDepth, canThrow) + ")";
}
function _createSimpleBinaryExpr(recurmax, noComma, stmtDepth, canThrow) {
// intentionally generate more hardcore ops
@@ -929,9 +934,12 @@ function createValue() {
return VALUES[rng(VALUES.length)];
}
-function createBinaryOp(noComma) {
- if (noComma) return BINARY_OPS_NO_COMMA[rng(BINARY_OPS_NO_COMMA.length)];
- return BINARY_OPS[rng(BINARY_OPS.length)];
+function createBinaryOp(noComma, canThrow) {
+ var op;
+ do {
+ op = BINARY_OPS[rng(BINARY_OPS.length)];
+ } while (noComma && op == "," || !canThrow && op == " in ");
+ return op;
}
function createAssignment() {