Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Ufuzz harmony code output #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@fabiosantoscode/uglify-es",
"name": "terser",
"description": "JavaScript parser, mangler/compressor and beautifier toolkit for ES6+",
"homepage": "https://github.com/fabiosantoscode/uglify-es",
"author": "Mihai Bazon <[email protected]> (http://lisperator.net/)",
Expand Down
11 changes: 10 additions & 1 deletion test/ufuzz.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ var VALUES = [
'2',
'3',
'4',
'5',
'0b110',
'22',
'-0', // 0/-0 !== 0
'23..toString()',
Expand Down Expand Up @@ -609,6 +609,12 @@ function createExpression(recurmax, noComma, stmtDepth, canThrow) {
return '((--b) + (' + _createExpression(recurmax, noComma, stmtDepth, canThrow) + '))';
case 2:
return '((c = c + 1) + (' + _createExpression(recurmax, noComma, stmtDepth, canThrow) + '))'; // c only gets incremented
case 3:
return '(() => '
+ _createExpression(recurmax, noComma, stmtDepth, canThrow)
+ ')('
+ _createExpression(recurmax, noComma, stmtDepth, canThrow)
+ ')'
default:
return '(' + _createExpression(recurmax, noComma, stmtDepth, canThrow) + ')';
}
Expand Down Expand Up @@ -762,6 +768,7 @@ function _createExpression(recurmax, noComma, stmtDepth, canThrow) {
return name + ' && ' + name + '.' + getDotKey();
case p++:
case p++:
return '(class {})'
case p++:
case p++:
var name = rng(3) == 0 ? getVarName() : 'f' + rng(funcs + 2);
Expand Down Expand Up @@ -848,6 +855,8 @@ function createObjectLiteral(recurmax, stmtDepth, canThrow) {
for (var i = rng(6); --i >= 0;) {
if (rng(20) == 0) {
obj.push(createAccessor(recurmax, stmtDepth, canThrow));
} else if (rng(4) < 2) {
obj.push(getVarName() + ',');
} else {
var key = KEYS[rng(KEYS.length)];
obj.push(key + ':(' + createExpression(recurmax, COMMA_OK, stmtDepth, canThrow) + '),');
Expand Down