Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions js/jsfunfuzz/test-math.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,27 @@ function testMathyFunction(f, inputs)
{
var results = [];
if (f) {
for (var j = 0; j < inputs.length; ++j) {
for (var k = 0; k < inputs.length; ++k) {
try {
results.push(f(inputs[j], inputs[k]));
} catch(e) {
results.push(errorToString(e));
}
}
}
testMathyFunctionRecursive(f, inputs, results, 0, 0);
}
/* Use uneval to distinguish -0, 0, "0", etc. */
/* Use hashStr to shorten the output and keep compareJIT files small. */
print(hashStr(uneval(results)));
}

function testMathyFunctionRecursive(f, inputs, results, j, k) {
try {
results.push(f(inputs[j], inputs[k]));
} catch(e) {
results.push(errorToString(e));
}

if (k < inputs.length() - 1) {
testMathyFunctionRecursive(f, inputs, results, j, k + 1);
} else if (j < inputs.length() -1) {
testMathyFunctionRecursive(f, inputs, results, j + 1, k);
}
}

function mathInitFCM()
{
// FCM cookie, lines with this cookie are used for compareJIT
Expand Down