🤡 parsePrinted
This commit is contained in:
@ -22,6 +22,7 @@ import Test.QuickCheck
|
||||
, listOf
|
||||
, suchThat
|
||||
, resize
|
||||
, withMaxSuccess
|
||||
)
|
||||
|
||||
genString :: Gen String
|
||||
@ -33,6 +34,8 @@ varTest s = (not (s `elem` keywords)) && ((length s) > 1)
|
||||
genVar :: Gen String
|
||||
genVar = suchThat (genString) (varTest)
|
||||
|
||||
genInt :: Gen Integer
|
||||
genInt = suchThat arbitrary (\i -> i >= 0)
|
||||
|
||||
instance Arbitrary Exp where
|
||||
arbitrary = sized (genExp [])
|
||||
@ -62,10 +65,10 @@ instance Arbitrary Exp where
|
||||
shrink _ = []
|
||||
|
||||
genExp :: [VName] -> Int -> Gen Exp
|
||||
genExp _ 0 = oneof [CstInt <$> arbitrary, CstBool <$> arbitrary]
|
||||
genExp _ 0 = oneof [CstInt <$> genInt, CstBool <$> arbitrary]
|
||||
genExp vars size =
|
||||
frequency
|
||||
[ (1, CstInt <$> arbitrary)
|
||||
[ (1, CstInt <$> genInt)
|
||||
, (1, CstBool <$> arbitrary)
|
||||
, (1, Add <$> genExp vars halfSize <*> genExp vars halfSize)
|
||||
, (1, Sub <$> genExp vars halfSize <*> genExp vars halfSize)
|
||||
@ -74,7 +77,7 @@ genExp vars size =
|
||||
, (1, Pow <$> genExp vars halfSize <*> genExp vars halfSize)
|
||||
, (1, Eql <$> genExp vars halfSize <*> genExp vars halfSize)
|
||||
, (1, If <$> genExp vars thirdSize <*> genExp vars thirdSize <*> genExp vars thirdSize)
|
||||
, (1, Var <$> arbitrary)
|
||||
, (1, Var <$> genVar)
|
||||
, (if (length vars) > 0 then 50 else 0, Var <$> elements vars)
|
||||
, (25, do
|
||||
var <- genVar
|
||||
@ -116,6 +119,6 @@ onlyCheckedErrors _ = undefined
|
||||
properties :: [(String, Property)]
|
||||
properties =
|
||||
[ ("expCoverage", property expCoverage)
|
||||
, ("parsePrinted", property parsePrinted)
|
||||
, ("parsePrinted", property (withMaxSuccess 10000 parsePrinted))
|
||||
, ("onlyCheckedErrors", property onlyCheckedErrors)
|
||||
]
|
||||
|
Reference in New Issue
Block a user