[Pkg-javascript-commits] [uglifyjs] 190/228: fuzz regexp literals, more constant numbers, typeof expression (#1755)

Jonas Smedegaard dr at jones.dk
Sat Apr 15 14:25:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

js pushed a commit to branch master
in repository uglifyjs.

commit 9a311705f53648388b8e6bd94c73f39aa15effeb
Author: kzc <kzc at users.noreply.github.com>
Date:   Sat Apr 1 14:08:46 2017 -0400

    fuzz regexp literals, more constant numbers, typeof expression (#1755)
---
 test/ufuzz.js | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git a/test/ufuzz.js b/test/ufuzz.js
index c011ea3..f0c0ea6 100644
--- a/test/ufuzz.js
+++ b/test/ufuzz.js
@@ -136,14 +136,24 @@ for (var i = 2; i < process.argv.length; ++i) {
 var VALUES = [
     'true',
     'false',
-    '22',
+    ' /[a2][^e]+$/ ',
+    '(-1)',
+    '(-2)',
+    '(-3)',
+    '(-4)',
+    '(-5)',
     '0',
+    '1',
+    '2',
+    '3',
+    '4',
+    '5',
+    '22',
     '-0', // 0/-0 !== 0
     '23..toString()',
     '24 .toString()',
     '25. ',
     '0x26.toString()',
-    '(-1)',
     'NaN',
     'undefined',
     'Infinity',
@@ -153,7 +163,12 @@ var VALUES = [
     '([,0].length === 2)', // an array with elisions... this is always true
     '({})', // wrapped the object causes too many syntax errors in statements
     '"foo"',
-    '"bar"' ];
+    '"bar"',
+    '"undefined"',
+    '"object"',
+    '"number"',
+    '"function"',
+];
 
 var BINARY_OPS_NO_COMMA = [
     ' + ', // spaces needed to disambiguate with ++ cases (could otherwise cause syntax errors)
@@ -257,6 +272,7 @@ var VAR_NAMES = [
 var INITIAL_NAMES_LEN = VAR_NAMES.length;
 
 var TYPEOF_OUTCOMES = [
+    'function',
     'undefined',
     'string',
     'number',
@@ -466,7 +482,7 @@ function createExpression(recurmax, noComma, stmtDepth, canThrow) {
     return _createExpression(recurmax, noComma, stmtDepth, canThrow);
 }
 function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
-    switch (rng(13)) {
+    switch (rng(15)) {
       case 0:
         return createUnaryOp() + (rng(2) === 1 ? 'a' : 'b');
       case 1:
@@ -540,6 +556,10 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
         }
       case 12:
         return createNestedBinaryExpr(recurmax, noComma);
+      case 13:
+        return " ((" + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + ") || a || 3).toString() ";
+      case 14:
+        return " /[abc4]/.test(((" + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + ") || b || 5).toString()) ";
     }
 }
 
@@ -562,7 +582,7 @@ function _createSimpleBinaryExpr(recurmax, noComma) {
 }
 
 function createTypeofExpr() {
-    switch (rng(5)) {
+    switch (rng(8)) {
       case 0:
         return 'typeof ' + createVarName(MANDATORY, DONT_STORE) + ' === "' + TYPEOF_OUTCOMES[rng(TYPEOF_OUTCOMES.length)] + '"';
       case 1:
@@ -573,6 +593,10 @@ function createTypeofExpr() {
         return 'typeof ' + createVarName(MANDATORY, DONT_STORE) + ' != "' + TYPEOF_OUTCOMES[rng(TYPEOF_OUTCOMES.length)] + '"';
       case 4:
         return 'typeof ' + createVarName(MANDATORY, DONT_STORE);
+      case 5:
+      case 6:
+      case 7:
+        return '(typeof ' + createExpression(3, COMMA_OK, 2, true) + ')';
     }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git



More information about the Pkg-javascript-commits mailing list