more generative test possibilities
This commit is contained in:
@@ -14,6 +14,12 @@
|
|||||||
(defMacroFunction _randomLetterString []
|
(defMacroFunction _randomLetterString []
|
||||||
(ReaderExp.StrExp (apply + (for _ (range (+ 1 (random (- maxStringLength 1)))) (chooseRandom (.split "abcdefghijklmnopqrstuvwxyz" ""))))))
|
(ReaderExp.StrExp (apply + (for _ (range (+ 1 (random (- maxStringLength 1)))) (chooseRandom (.split "abcdefghijklmnopqrstuvwxyz" ""))))))
|
||||||
|
|
||||||
|
(defMacroFunction _randomInt []
|
||||||
|
(symbol (Std.string (random maxInt))))
|
||||||
|
|
||||||
|
(defMacroFunction _randomFloat []
|
||||||
|
(symbol (Std.string (+ (random maxInt) (/ 1 (random maxInt))))))
|
||||||
|
|
||||||
(defMacroFunction _randomFalsyExp []
|
(defMacroFunction _randomFalsyExp []
|
||||||
((chooseRandom
|
((chooseRandom
|
||||||
[
|
[
|
||||||
@@ -34,7 +40,18 @@
|
|||||||
((chooseRandom
|
((chooseRandom
|
||||||
[
|
[
|
||||||
->{`true}
|
->{`true}
|
||||||
->{(_randomLetterString)}
|
->(_randomLetterString)
|
||||||
|
->(_randomInt)
|
||||||
|
->(_randomFloat)
|
||||||
|
// These cause stack overflows because it's hard to implement a recursion limit at macro time
|
||||||
|
/*->{`[,@(_randomLengthMacroList _randomLetterString)]}
|
||||||
|
->{`[,@(_randomLengthMacroList _randomInt)]}
|
||||||
|
->{`[,@(_randomLengthMacroList _randomFloat)]}
|
||||||
|
->{`(and ,@(_randomLengthMacroList _randomTruthyExp))}
|
||||||
|
->{`(or
|
||||||
|
,@(_randomLengthMacroList _randomUncertainExp)
|
||||||
|
,(_randomTruthyExp)
|
||||||
|
,@(_randomLengthMacroList _randomUncertainExp))}*/
|
||||||
])))
|
])))
|
||||||
(defMacro randomTruthyExp []
|
(defMacro randomTruthyExp []
|
||||||
(printExp (_randomTruthyExp) "Truthy"))
|
(printExp (_randomTruthyExp) "Truthy"))
|
||||||
@@ -45,8 +62,6 @@
|
|||||||
->(_randomFalsyExp)
|
->(_randomFalsyExp)
|
||||||
->(_randomTruthyExp)
|
->(_randomTruthyExp)
|
||||||
])))
|
])))
|
||||||
(defMacro randomUncertainExp []
|
|
||||||
(_randomUncertainExp))
|
|
||||||
|
|
||||||
(function _testTruthy []
|
(function _testTruthy []
|
||||||
(macroRepeat (Assert.isTrue ?(randomTruthyExp)) 10))
|
(macroRepeat (Assert.isTrue ?(randomTruthyExp)) 10))
|
||||||
|
Reference in New Issue
Block a user