smallcheck

How much should one control the `Depth` parameter in smallcheck?

无人久伴 提交于 2020-01-14 09:38:27
问题 I'm doing my first bit of real work with smallcheck , and I'm a little confused about how to use the Depth parameter. Before I go into that, let me state what I'm using smallcheck for. At work, we're building a simple web service in front of our own in-house database. The web service does some queries, and responds with the query results serialized to JSON. What I'm working on at the moment is the assurance that: given an object that represents the results of a query, this object produces the

SmallCheck: Making types instance of typeclass Serial

大兔子大兔子 提交于 2019-12-24 03:49:20
问题 I'm trying to figure out how to use the smallcheck property-based test library in conjunction with tasty. I ran into a problem with multi-field record types: How can I make a record type with mor than 4 fields member of the Serial typeclass? I assume that this would be the normal way to go: {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} import Test.Tasty import Test.Tasty.SmallCheck import Test.SmallCheck.Series data T1 = T1 { p1 :: Int, p2 :: Char, p3 :: [Int] } deriving (Show, Eq

Why does smallCheck's `Series` class have two types in the constructor?

梦想与她 提交于 2019-12-13 15:14:15
问题 This question is related to my other question about smallCheck 's Test.SmallCheck.Series class. When I try to define an instance of the class Serial in the following natural way (suggested to me by an answer by @tel to the above question), I get compiler errors: data Person = SnowWhite | Dwarf Int instance Serial Person where ... It turns out that Serial wants to have two arguments. This, in turn, necessitates a some compiler flags. The following works: {-# LANGUAGE FlexibleInstances,

Haskell / SmallCheck: How to control the `Depth` parameter?

爷,独闯天下 提交于 2019-12-10 15:56:23
问题 I have a simple data structure to test in smallcheck. {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} {-# LANGUAGE DeriveGeneric #-} import Test.Tasty import Test.Tasty.SmallCheck import Test.SmallCheck.Series import GHC.Generics data T1 = T1 { p1 :: Int, p2 :: Char, p3 :: [Int] } deriving (Eq, Show, Generic) instance Monad m => Serial m T1 main :: IO () main = defaultMain tests tests :: TestTree tests = testGroup "Tests" [scProps] scProps = testGroup "(checked by SmallCheck)" [

SmallCheck generate data satisfying invariants

∥☆過路亽.° 提交于 2019-12-08 03:43:25
问题 I want to use SmallCheck to test my code. I managed to generate arbitrary lists of pairs of ints, but that's not what my type should contain. The list represents a set of ranges, where [1,3),[4,6) would be encoded/stored as [(1,3),(4,6)] . These are the invariants for the normalized form of my ranges: fst a < snd a snd a < fst b where a is before b in the list I would like to communicate this to SmallCheck so that it doesn't generate loads of values that I throw away, because they aren't

How to use SmallCheck in Haskell?

狂风中的少年 提交于 2019-11-30 11:22:40
I am trying to use SmallCheck to test a Haskell program, but I cannot understand how to use the library to test my own data types. Apparently, I need to use the Test.SmallCheck.Series . However, I find the documentation for it extremely confusing. I am interested in both cookbook-style solutions and an understandable explanation of the logical (monadic?) structure. Here are some questions I have (all related): If I have a data type data Person = SnowWhite | Dwarf Integer , how do I explain to smallCheck that the valid values are Dwarf 1 through Dwarf 7 (or SnowWhite )? What if I have a

How to use SmallCheck in Haskell?

ε祈祈猫儿з 提交于 2019-11-29 17:37:15
问题 I am trying to use SmallCheck to test a Haskell program, but I cannot understand how to use the library to test my own data types. Apparently, I need to use the Test.SmallCheck.Series. However, I find the documentation for it extremely confusing. I am interested in both cookbook-style solutions and an understandable explanation of the logical (monadic?) structure. Here are some questions I have (all related): If I have a data type data Person = SnowWhite | Dwarf Integer , how do I explain to