(macroDepth) and generativetestcase depth limit
This commit is contained in:
@@ -337,6 +337,7 @@ class Helpers {
|
|||||||
}
|
}
|
||||||
// This is kind of a big deal:
|
// This is kind of a big deal:
|
||||||
interp.variables.set("eval", Helpers.runAtCompileTimeDynamic.bind(_, k));
|
interp.variables.set("eval", Helpers.runAtCompileTimeDynamic.bind(_, k));
|
||||||
|
interp.variables.set("macroDepth", () -> interps.length);
|
||||||
|
|
||||||
interps.push(interp);
|
interps.push(interp);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
(defMacroVar maxInt 1000000000)
|
(defMacroVar maxInt 1000000000)
|
||||||
(defMacroVar maxStringLength 20)
|
(defMacroVar maxStringLength 20)
|
||||||
(defMacroVar maxExps 4)
|
(defMacroVar maxExps 4)
|
||||||
|
(defMacroVar maxDepth 15)
|
||||||
|
|
||||||
(defMacroFunction _macroList [func length]
|
(defMacroFunction _macroList [func length]
|
||||||
(for _ (range length) (func)))
|
(for _ (range length) (func)))
|
||||||
@@ -22,37 +23,46 @@
|
|||||||
|
|
||||||
(defMacroFunction _randomFalsyExp []
|
(defMacroFunction _randomFalsyExp []
|
||||||
((chooseRandom
|
((chooseRandom
|
||||||
|
(concat
|
||||||
[
|
[
|
||||||
->{`null}
|
->{`null}
|
||||||
->{`false}
|
->{`false}
|
||||||
->{`""}
|
->{`""}
|
||||||
->{`[]}
|
->{`[]}
|
||||||
|
]
|
||||||
|
(if (< (macroDepth) maxDepth)
|
||||||
|
[
|
||||||
->{`(or ,@(_randomLengthMacroList _randomFalsyExp))}
|
->{`(or ,@(_randomLengthMacroList _randomFalsyExp))}
|
||||||
->{`(and
|
->{`(and
|
||||||
,@(_randomLengthMacroList _randomUncertainExp)
|
,@(_randomLengthMacroList _randomUncertainExp)
|
||||||
,(_randomFalsyExp)
|
,(_randomFalsyExp)
|
||||||
,@(_randomLengthMacroList _randomUncertainExp))}
|
,@(_randomLengthMacroList _randomUncertainExp))}
|
||||||
])))
|
]
|
||||||
|
[])))))
|
||||||
(defMacro randomFalsyExp []
|
(defMacro randomFalsyExp []
|
||||||
(printExp (_randomFalsyExp) "Falsy"))
|
(printExp (_randomFalsyExp) "Falsy"))
|
||||||
|
|
||||||
(defMacroFunction _randomTruthyExp []
|
(defMacroFunction _randomTruthyExp []
|
||||||
((chooseRandom
|
((chooseRandom
|
||||||
|
(concat
|
||||||
[
|
[
|
||||||
->{`true}
|
->{`true}
|
||||||
->(_randomLetterString)
|
->(_randomLetterString)
|
||||||
->(_randomInt)
|
->(_randomInt)
|
||||||
->(_randomFloat)
|
->(_randomFloat)
|
||||||
// These cause stack overflows because it's hard to implement a recursion limit at macro time
|
]
|
||||||
/*->{`[,@(_randomLengthMacroList _randomLetterString)]}
|
(if (< (macroDepth) maxDepth)
|
||||||
|
[
|
||||||
|
->{`[,@(_randomLengthMacroList _randomLetterString)]}
|
||||||
->{`[,@(_randomLengthMacroList _randomInt)]}
|
->{`[,@(_randomLengthMacroList _randomInt)]}
|
||||||
->{`[,@(_randomLengthMacroList _randomFloat)]}
|
->{`[,@(_randomLengthMacroList _randomFloat)]}
|
||||||
->{`(and ,@(_randomLengthMacroList _randomTruthyExp))}
|
->{`(and ,@(_randomLengthMacroList _randomTruthyExp))}
|
||||||
->{`(or
|
->{`(or
|
||||||
,@(_randomLengthMacroList _randomUncertainExp)
|
,@(_randomLengthMacroList _randomUncertainExp)
|
||||||
,(_randomTruthyExp)
|
,(_randomTruthyExp)
|
||||||
,@(_randomLengthMacroList _randomUncertainExp))}*/
|
,@(_randomLengthMacroList _randomUncertainExp))}
|
||||||
])))
|
]
|
||||||
|
[])))))
|
||||||
(defMacro randomTruthyExp []
|
(defMacro randomTruthyExp []
|
||||||
(printExp (_randomTruthyExp) "Truthy"))
|
(printExp (_randomTruthyExp) "Truthy"))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user