winery-1.1.3: A compact, well-typed seralisation format for Haskell values

Copyright(c) Fumiaki Kinoshita 2019
LicenseBSD3
StabilityExperimental
Safe HaskellNone
LanguageHaskell2010

Codec.Winery.Test

Contents

Description

Maintainer : Fumiaki Kinoshita fumiexcel@gmail.com

A test framework that allows you to test all related Serialise instances with automatically-generated test cases

Synopsis

Generating tests

class Typeable a => TestGen a where Source #

A class to provide test values and gather tests for its components. It is recommended to use the generic default methods.

Minimal complete definition

Nothing

Methods

genTestCases :: [a] Source #

A list of values that can be used as test cases. It should contain at least one value as long as there is a non-bottom value in the type.

inheritedTests :: Proxy a -> Map TypeRep [Test] Source #

Inherited set of test cases for each type it involves.

genTestCases :: (Generic a, GTestGen (Rep a)) => [a] Source #

A list of values that can be used as test cases. It should contain at least one value as long as there is a non-bottom value in the type.

inheritedTests :: GTestGen (Rep a) => Proxy a -> Map TypeRep [Test] Source #

Inherited set of test cases for each type it involves.

Instances
TestGen Bool Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Char Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Double Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Float Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Int Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Word8 Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Word16 Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Word32 Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Word64 Source # 
Instance details

Defined in Codec.Winery.Test

TestGen () Source # 
Instance details

Defined in Codec.Winery.Test

TestGen ByteString Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Text Source # 
Instance details

Defined in Codec.Winery.Test

TestGen Void Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => TestGen [a] Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => TestGen (Maybe a) Source # 
Instance details

Defined in Codec.Winery.Test

TestGen a => TestGen (Identity a) Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => TestGen (Seq a) Source # 
Instance details

Defined in Codec.Winery.Test

(Ord a, Tested a) => TestGen (Set a) Source # 
Instance details

Defined in Codec.Winery.Test

(Unbox a, Tested a) => TestGen (Vector a) Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => TestGen (Vector a) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b) => TestGen (Either a b) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b) => TestGen (a, b) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

genTestCases :: [(a, b)] Source #

inheritedTests :: Proxy (a, b) -> Map TypeRep [Test] Source #

(Hashable k, Tested k, Tested a) => TestGen (HashMap k a) Source # 
Instance details

Defined in Codec.Winery.Test

(Ord k, Tested k, Tested a) => TestGen (Map k a) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b, Tested c) => TestGen (a, b, c) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

genTestCases :: [(a, b, c)] Source #

inheritedTests :: Proxy (a, b, c) -> Map TypeRep [Test] Source #

(Tested a, Tested b, Tested c, Tested d) => TestGen (a, b, c, d) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

genTestCases :: [(a, b, c, d)] Source #

inheritedTests :: Proxy (a, b, c, d) -> Map TypeRep [Test] Source #

printTests :: forall a. (TestGen a, Serialise a, Show a) => IO () Source #

Generate test cases and print them to the standard output.

buildTestGroups :: forall a. (TestGen a, Serialise a) => [(Schema, [(ByteString, a)])] Source #

Test cases

class TestGen a => Tested a where Source #

Types with concrete test cases.

/"Doubt is useful, it keeps faith a living thing. After all, you cannot know the strength of your faith until it has been tested."/

Minimal complete definition

testGroups | testCases

Methods

testCases :: [Test] Source #

List of test cases for the type.

testCases :: (Serialise a, Eq a, Show a) => [Test] Source #

List of test cases for the type.

testGroups :: [(Schema, [(ByteString, a)])] Source #

Instances
Tested Bool Source # 
Instance details

Defined in Codec.Winery.Test

Tested Char Source # 
Instance details

Defined in Codec.Winery.Test

Tested Double Source # 
Instance details

Defined in Codec.Winery.Test

Tested Float Source # 
Instance details

Defined in Codec.Winery.Test

Tested Int Source # 
Instance details

Defined in Codec.Winery.Test

Tested Word8 Source # 
Instance details

Defined in Codec.Winery.Test

Tested Word16 Source # 
Instance details

Defined in Codec.Winery.Test

Tested Word32 Source # 
Instance details

Defined in Codec.Winery.Test

Tested Word64 Source # 
Instance details

Defined in Codec.Winery.Test

Tested () Source # 
Instance details

Defined in Codec.Winery.Test

Tested ByteString Source # 
Instance details

Defined in Codec.Winery.Test

Tested Text Source # 
Instance details

Defined in Codec.Winery.Test

Tested Void Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => Tested [a] Source # 
Instance details

Defined in Codec.Winery.Test

Methods

testCases :: [Test] Source #

testGroups :: [(Schema, [(ByteString, [a])])] Source #

Tested a => Tested (Maybe a) Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => Tested (Identity a) Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => Tested (Seq a) Source # 
Instance details

Defined in Codec.Winery.Test

(Ord a, Tested a) => Tested (Set a) Source # 
Instance details

Defined in Codec.Winery.Test

(Unbox a, Tested a) => Tested (Vector a) Source # 
Instance details

Defined in Codec.Winery.Test

Tested a => Tested (Vector a) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b) => Tested (Either a b) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b) => Tested (a, b) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

testCases :: [Test] Source #

testGroups :: [(Schema, [(ByteString, (a, b))])] Source #

(Hashable k, Tested k, Tested a) => Tested (HashMap k a) Source # 
Instance details

Defined in Codec.Winery.Test

(Ord k, Tested k, Tested a) => Tested (Map k a) Source # 
Instance details

Defined in Codec.Winery.Test

(Tested a, Tested b, Tested c) => Tested (a, b, c) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

testCases :: [Test] Source #

testGroups :: [(Schema, [(ByteString, (a, b, c))])] Source #

(Tested a, Tested b, Tested c, Tested d) => Tested (a, b, c, d) Source # 
Instance details

Defined in Codec.Winery.Test

Methods

testCases :: [Test] Source #

testGroups :: [(Schema, [(ByteString, (a, b, c, d))])] Source #

testCase Source #

Arguments

:: (Show a, Eq a, Serialise a) 
=> Schema

the schema

-> ByteString

serialised

-> a

expected

-> Test 

Construct a test case.

Running tests

allTests :: forall a. (TestGen a, Tested a) => Map TypeRep [Test] Source #

Gather all test cases involved in the specified type.

mergeTests :: Map TypeRep [Test] -> Test Source #

Merge multiple tests into one.