packages feed

doctest-prop (empty) → 0.1.0.0

raw patch · 5 files changed

+118/−0 lines, 5 filesdep +QuickCheckdep +basedep +doctestsetup-changed

Dependencies added: QuickCheck, base, doctest

Files

+ LICENSE view
@@ -0,0 +1,20 @@+Copyright (c) 2012 Takayuki Muranushi++Permission is hereby granted, free of charge, to any person obtaining+a copy of this software and associated documentation files (the+"Software"), to deal in the Software without restriction, including+without limitation the rights to use, copy, modify, merge, publish,+distribute, sublicense, and/or sell copies of the Software, and to+permit persons to whom the Software is furnished to do so, subject to+the following conditions:++The above copyright notice and this permission notice shall be+included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ doctest-prop.cabal view
@@ -0,0 +1,44 @@+-- Initial doctest-prop.cabal generated by cabal init.  For further +-- documentation, see http://haskell.org/cabal/users-guide/++name:                doctest-prop+version:             0.1.0.0+synopsis:            Allow QuickCheck-style property testing within doctest.+description:         +  This package allows you to write QuickCheck properties within+  doctest, using functions that keep silence when test succeeds and+  print out the test outputs otherwise.+  .+  To enjoy behavior driven development in Haskell, first import+  @Test.DocTest.Prop@, and use @prop@, @propWith@ and @unit@ to write+  in-place tests. For more details, please refer to examples in the module+  @Test.DocTest.Prop@ .++license:             MIT+license-file:        LICENSE+author:              Takayuki Muranushi+maintainer:          muranushi@gmail.com+-- copyright:           +category:            Testing+build-type:          Simple+cabal-version:       >=1.8+++library+  exposed-modules:     Test.DocTest.Prop+  hs-source-dirs:    ./src/+  build-depends:       base ==4.*+                     , QuickCheck++Test-Suite test+  Main-Is:           main.hs+  hs-source-dirs:    ./test/, .+  Type:              exitcode-stdio-1.0+  Build-Depends:     base == 4.*+                   , doctest >=0.8+                   , QuickCheck++source-repository head+  type:              git+  location:          git://github.com/nushio3/doctest-prop.git+  
+ src/Test/DocTest/Prop.hs view
@@ -0,0 +1,49 @@+{-# Options -Wall #-}+{-|++This package allows you to write QuickCheck properties within doctest,+using functions that keep silence when test succeeds and print out the+test outputs otherwise.++To enjoy behavior driven development in Haskell, first import+@Test.DocTest.Prop@, and use @prop@, @propWith@ and @unit@ to write+in-place tests, as follows.++>>> import Test.DocTest.Prop+>>> prop $ \x -> x*2 == x+x+>>> prop ((<2) . fromEnum :: Bool -> Bool)+>>> propWith (quietArgs{maxSize=3}) $ (<10).length+>>> unit $ 1+1==2++-}++module Test.DocTest.Prop+       (prop, propWith, quietArgs, unit) where+++import Test.QuickCheck++-- | The standard arguments for QuickCheck but the chatty flag is off.+quietArgs :: Args+quietArgs = stdArgs {chatty = False}++-- | Test the QuickCheck property.+prop :: Testable p => p -> IO ()+prop p = do+  r <- quickCheckWithResult quietArgs p+  case r of+    Success _ _ _ -> return ()+    _ -> putStrLn $ output r++-- | @prop@ with customized arguments.+propWith :: Testable p => Args -> p -> IO ()+propWith args p = do+  r <- quickCheckWithResult args  p+  case r of+    Success _ _ _ -> return ()+    _ -> putStrLn $ output r++-- | Test for an unchanging property.+unit :: Bool -> IO ()+unit True  = return ()+unit False = putStrLn "Failure"
+ test/main.hs view
@@ -0,0 +1,3 @@+import Test.DocTest++main = doctest ["src/Test/DocTest/Prop.hs"]