tasty-test-vector (empty) → 0
raw patch · 5 files changed
+108/−0 lines, 5 filesdep +basedep +tastysetup-changed
Dependencies added: base, tasty
Files
- CHANGELOG.md +5/−0
- LICENSE +30/−0
- Setup.hs +2/−0
- src/Test/Tasty/TestVector.hs +36/−0
- tasty-test-vector.cabal +35/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for tasty-test-vector++## 0 -- 2018-12-18++* First version.
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright (c) 2018, davean++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * Neither the name of davean nor the names of other+ contributors may be used to endorse or promote products derived+ from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ src/Test/Tasty/TestVector.hs view
@@ -0,0 +1,36 @@+{-# LANGUAGE ExistentialQuantification #-}++-- | Test vector support for tasty.++module Test.Tasty.TestVector (+ testVectors+ ) where++import Data.Bifunctor+import Data.List (intercalate, partition)+import Test.Tasty.Providers+import Data.Typeable+import Text.Printf++data TV =+ forall a b . Show a => TV (a -> b -> Bool) [(a, b)]+ deriving Typeable++-- | Turn a function and a list of parameters for it into a single tasty test.+--+-- Any specific failing test vectors are reported individually by showing the+-- first part of the test vector tuple.+testVectors :: Show a => TestName -> (a -> b -> Bool) -> [(a, b)] -> TestTree+testVectors name f vs = singleTest name $ TV f vs++instance IsTest TV where+ testOptions = pure mempty+ run _opts (TV f vs) _yieldProgress = do+ let failed = map fst . filter (not.uncurry f) $ vs+ pure $ if null failed+ then testPassed $ printf "+++ OK, passed %d test vectors." (length vs)+ else testFailed $+ printf "*** FAILED! Failed %d/%d tests, failed on:\n%s"+ (length failed) (length vs) $+ intercalate "\n" $+ map show failed
+ tasty-test-vector.cabal view
@@ -0,0 +1,35 @@+cabal-version: 2.2++name: tasty-test-vector+version: 0+synopsis: Test vector support for tasty.+description:+ Many specifications provide test vectors for their algorithms, particularly+ specifications for cryptographic primatives. These are like QuickCheck properties+ in that they provide some function input and check the output, but unlike QuickCheck+ the inputs and expected results are predefined.+ .+ This library provides an interface for cleanly integrating such test vectors into+ the 'tasty' test framework.+homepage: https://oss.xkcd.com/+bug-reports: https://code.xkrd.net/haskell/tasty-test-vector/issues+license: BSD-3-Clause+license-file: LICENSE+author: davean+maintainer: oss@xkcd.com+copyright: Copyright (C) 2018 davean+category: Testing+extra-source-files: CHANGELOG.md++source-repository head+ type: git+ location: https://code.xkrd.net/haskell/tasty-test-vector.git++library+ default-language: Haskell2010+ hs-source-dirs: src+ exposed-modules:+ Test.Tasty.TestVector+ build-depends:+ base ^>=4.12.0.0+ , tasty ^>=1.2