forked from MozillaSecurity/funfuzz
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmess-grammar.js
More file actions
56 lines (50 loc) · 1.18 KB
/
mess-grammar.js
File metadata and controls
56 lines (50 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Randomly ignore the grammar 1 in TOTALLY_RANDOM times we generate any grammar node.
var TOTALLY_RANDOM = 1000;
var allMakers = getListOfMakers(this);
function totallyRandom(d, b) {
d = d + (rnd(5) - 2); // can increase!!
var maker = Random.index(allMakers);
var val = maker(d, b);
if (typeof val != "string") {
print(maker.name);
print(maker);
throw "We generated something that isn't a string!";
}
return val;
}
function getListOfMakers(glob)
{
var r = [];
for (var f in glob) {
if (f.indexOf("make") == 0 && typeof glob[f] == "function" && f != "makeFinalizeObserver" && f != "makeFakePromise") {
r.push(glob[f]);
}
}
return r;
}
/*
function testEachMaker()
{
for (var f of allMakers) {
dumpln("");
dumpln(f.name);
dumpln("==========");
dumpln("");
for (var i = 0; i < 100; ++i) {
try {
var r = f(8, ["A", "B"]);
if (typeof r != "string")
throw ("Got a " + typeof r);
dumpln(r);
} catch(e) {
dumpln("");
dumpln(uneval(e));
dumpln(e.stack);
dumpln("");
throw "testEachMaker found a bug in jsfunfuzz";
}
}
dumpln("");
}
}
*/