UNPKG

esfuzz

Version:

JS fuzzer for generative testing of parsers that implement the SpiderMonkey Reflect.parse API

75 lines (74 loc) 2.66 kB
// Generated by CoffeeScript 2.0.0-beta7 void function () { var cache$, listOf, listOfExactly, oneOf, randomBool, randomElement; cache$ = require('./random'); randomBool = cache$.randomBool; randomElement = cache$.randomElement; exports.oneOf = oneOf = function (possibleGenerators) { return function (args) { var cache$1; args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; return (cache$1 = randomElement(possibleGenerators)).apply(cache$1, [].slice.call(args).concat()); }; }; exports.listOf = listOf = function (possibleGenerators) { return function (args) { args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; return function (accum$) { var cache$1; while (Math.random() < .5) { accum$.push((cache$1 = oneOf(possibleGenerators)).apply(cache$1, [].slice.call(args).concat())); } return accum$; }.call(this, []); }; }; exports.listOfExactly = listOfExactly = function (n, possibleGenerators) { return function (args) { args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; return function (accum$) { var cache$2; for (var cache$1 = function () { var accum$1; accum$1 = []; for (var i$ = 1; 1 <= n ? i$ <= n : i$ >= n; 1 <= n ? ++i$ : --i$) accum$1.push(i$); return accum$1; }.apply(this, arguments), i$ = 0, length$ = cache$1.length; i$ < length$; ++i$) { accum$.push((cache$2 = oneOf(possibleGenerators)).apply(cache$2, [].slice.call(args).concat())); } return accum$; }.call(this, []); }; }; exports.listOfAtLeast = function (min, possibleGenerators) { return function (args) { var cache$1, post, pre; args = 1 <= arguments.length ? [].slice.call(arguments, 0) : []; pre = listOfExactly(min, possibleGenerators)(); post = (cache$1 = listOf(possibleGenerators)).apply(cache$1, [].slice.call(args).concat()); return [].slice.call(pre).concat([].slice.call(post)); }; }; exports.maybe = function (generator) { if (randomBool()) { return generator; } else { return function () { return null; }; } }; exports.construct = function (C) { return function () { return construct$(C, [].slice.call(arguments).concat()); }; }; function construct$(ctor, args) { var fn = function () { }; fn.prototype = ctor.prototype; var child = new fn, result = ctor.apply(child, args); return result === Object(result) ? result : child; } }.call(this);