hspecVariant: Spec for testing properties for variant types

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Spec for testing properties for variant types


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.0.0, 0.1.0.1, 1.0.0.0, 1.0.1.0
Change log None available
Dependencies base (>=4.6 && <5), hspec (>=2.2 && <3), QuickCheckVariant (==0.1.1.0) [details]
License GPL-3.0-only
Copyright (c) Jorge Santiago Alvarez Cuadros
Author Jorge Santiago Alvarez Cuadros
Maintainer sanjorgek@ciencias.unam.mx
Category Testing
Home page https://github.com/sanjorgek/hspecVariant
Bug tracker https://github.com/sanjorgek/hspecVariant/issues
Source repo head: git clone git@github.com:sanjorgek/hspecVariant.git
Uploaded by sanjorgek at 2016-07-28T01:06:00Z

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for hspecVariant-0.1.0.0

[back to package description]

hspecVariant

Spec for testing properties for variant types

{-# LANGUAGE TypeSynonymInstances #-}

type Natural = Integer

instance Variant Natural where
  invalid = do
    n <- arbitrary
    if (n<0) then return n else return ((-1)*(n+1))
  valid = do
    n <- arbitrary
    if (n>=0) then return n else return ((-1)*(n+1))

Test

main::IO ()
main = hspec $
  describe "Naturals" $
    propValid "succ" $
      \x -> succ (x::Natural) > 0