Giter Site home page Giter Site logo

rudymatela / tasty-leancheck Goto Github PK

View Code? Open in Web Editor NEW
1.0 5.0 1.0 65 KB

LeanCheck support for the Tasty test framework (Haskell)

License: BSD 3-Clause "New" or "Revised" License

Makefile 38.95% Haskell 37.98% Shell 23.07%
haskell leancheck tasty testing testing-tools testing-framework

tasty-leancheck's Introduction

tasty-leancheck: LeanCheck support for Tasty

tasty-leancheck's Build Status tasty-leancheck on Hackage tasty-leancheck on Stackage LTS tasty-leancheck on Stackage Nightly

LeanCheck support for the Tasty test framework. Tasty and healthy tests.

Installing

$ cabal install tasty-leancheck

Example

(This example is intentionally similar to Tasty's official example.)

Here's how your test.hs might look like:

import Test.Tasty
import Test.Tasty.LeanCheck as LC
import Data.List

main :: IO ()
main = defaultMain tests

tests :: TestTree
tests = testGroup "Test properties checked by LeanCheck"
  [ LC.testProperty "sort == sort . reverse" $
      \list -> sort (list :: [Int]) == sort (reverse list)
  , LC.testProperty "Fermat's little theorem" $
      \x -> ((x :: Integer)^7 - x) `mod` 7 == 0
  -- the following property do not hold
  , LC.testProperty "Fermat's last theorem" $
      \x y z n ->
        (n :: Integer) >= 3 LC.==> x^n + y^n /= (z^n :: Integer)
  ]

And here is the output for the above program:

$ ./test
Test properties checked by LeanCheck
  sort == sort . reverse:  OK
    +++ OK, passed 200 tests.
  Fermat's little theorem: OK
    +++ OK, passed 200 tests.
  Fermat's last theorem:   FAIL
    *** Failed! Falsifiable (after 71 tests):
    0 0 0 3

1 out of 3 tests failed (0.00s)

Options

The tasty-leancheck provider has only one option, --leancheck-tests:

$ ./test --leancheck-tests 10
Test properties checked by LeanCheck
  sort == sort . reverse:  OK
    +++ OK, passed 10 tests.
  Fermat's little theorem: OK
    +++ OK, passed 10 tests.
  Fermat's last theorem:   OK
    +++ OK, passed 10 tests.

All 3 tests passed (0.00s)

Further reading

tasty-leancheck's People

Contributors

rudymatela avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

strake

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.