quickcheck-poly 0.2.0.0 → 0.2.0.1
raw patch · 7 files changed
+122/−86 lines, 7 files
Files
- LICENSE +31/−0
- Main.hs +0/−71
- Prop.hs +0/−12
- Test/QuickCheck/PolyQC.hs +5/−1
- quickcheck-poly.cabal +3/−2
- test/Main.hs +71/−0
- test/Prop.hs +12/−0
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright (c) 2009, Ki Yung Ahn++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 Ki Yung Ahn 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.
− Main.hs
@@ -1,71 +0,0 @@--- vim: sw=2: ts=2: expandtab:--module Main where--import Test.QuickCheck.PolyQC--import Prop -- the module that defiens the properties p0, p1, p2, p3, p4- -- p0 x = x == x- -- p1 x y z = x + (y + z) == (x + y) + z- -- p2 x y = x + y == y + x- -- p3 x = x == negate (negate x)- -- p4 p = (fst p, snd p) == p--main = do putStrLn "testing p0 ======================================="- print =<< polyQuickCheck' "Prop" "p0" ["Bool","Int","Double"]- putStrLn "testing p1 ======================================="- print =<< polyQuickCheck' "Prop" "p1" ["Bool","Int","Double"]- putStrLn "testing p2 ======================================="- print =<< polyQuickCheck' "Prop" "p2" ["Bool","Int","Double"]- putStrLn "testing p3 ======================================="- print =<< polyQuickCheck' "Prop" "p3" ["Bool","Int","Double"]- putStrLn "testing p4 ======================================="- print =<< polyQuickCheck' "Prop" "p4" ["Bool","Int","Double"]- return ()--{---*Main> :t p0-p0 :: (Eq a) => a -> Bool-*Main> :t p1-p1 :: (Num a) => a -> a -> a -> Bool-*Main> :t p2-p2 :: (Num a) => a -> a -> Bool-*Main> :t p3-p3 :: (Num a) => a -> Bool-*Main> :t p4-p4 :: (Eq a, Eq b) => (a, b) -> Bool-*Main> main-testing p0 =======================================-Right ["(\"(Eq Bool) => Bool -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Int) => Int -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Double) => Double -> Bool\",+++ OK, passed 100 tests.-())"]-testing p1 =======================================-Right ["(\"(Num Int) => Int -> Int -> Int -> Bool\",+++ OK, passed 100 tests.-())","(\"(Num Double) => Double -> Double -> Double -> Bool\",*** Failed! Falsifiable (after 9 tests and 2 shrinks): -4.0--26.0-8.777291602197652-())"]-testing p2 =======================================-Right ["(\"(Num Int) => Int -> Int -> Bool\",+++ OK, passed 100 tests.-())","(\"(Num Double) => Double -> Double -> Bool\",+++ OK, passed 100 tests.-())"]-testing p3 =======================================-Right ["(\"(Num Int) => Int -> Bool\",+++ OK, passed 100 tests.-())","(\"(Num Double) => Double -> Bool\",+++ OK, passed 100 tests.-())"]-testing p4 =======================================-Right ["(\"(Eq Bool, Eq Bool) => (Bool, Bool) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Bool, Eq Int) => (Bool, Int) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Bool, Eq Double) => (Bool, Double) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Int, Eq Bool) => (Int, Bool) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Int, Eq Int) => (Int, Int) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Int, Eq Double) => (Int, Double) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Double, Eq Bool) => (Double, Bool) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Double, Eq Int) => (Double, Int) -> Bool\",+++ OK, passed 100 tests.-())","(\"(Eq Double, Eq Double) => (Double, Double) -> Bool\",+++ OK, passed 100 tests.-())"]---}
− Prop.hs
@@ -1,12 +0,0 @@--- vim: sw=2: ts=2: expandtab:-module Prop where--p0 x = x == x--p1 x y z = x + (y + z) == (x + y) + z--p2 x y = x + y == y + x--p3 x = x == negate (negate x)--p4 p = (fst p, snd p) == p
Test/QuickCheck/PolyQC.hs view
@@ -141,9 +141,13 @@ [if any isSpace t then paren t else t | t<-ts] monotys = [foldr (.) id (map subRegexString subs) $ ty | subs <- allsubs] tys' <- filterM (\t -> GHCi.typeChecks $ e++" :: "++t) monotys+ -- mapM GHCi.eval+ -- ["liftM2 (,) (return "++show t++") " +++ -- "Test.QuickCheck."++qcFun++" ("++e++" :: "++t++")" | t <- tys'] mapM GHCi.eval- ["liftM2 (,) (return "++show t++") " +++ ["putStr "++show t++" >> putStr [' '] >> " ++ "Test.QuickCheck."++qcFun++" ("++e++" :: "++t++")" | t <- tys']+ polyQuickCheck :: (Control.Monad.CatchIO.MonadCatchIO m, Functor m) =>
quickcheck-poly.cabal view
@@ -1,6 +1,7 @@ Name: quickcheck-poly-Version: 0.2.0.0+Version: 0.2.0.1 License: BSD3+License-file: LICENSE Author: Ahn, Ki Yung Maintainer: Ahn, Ki Yung <kya@pdx.edu> Category: Testing @@ -12,4 +13,4 @@ hint >= 0.3, regex-tdfa >= 1.1, regex-compat, MonadCatchIO-mtl >= 0.2 Exposed-modules: Test.QuickCheck.PolyQC, Test.QuickCheck.UnsafeShowIO-Extra-source-files: Main.hs, Prop.hs+Extra-source-files: test/Main.hs, test/Prop.hs
+ test/Main.hs view
@@ -0,0 +1,71 @@+-- vim: sw=2: ts=2: expandtab:++module Main where++import Test.QuickCheck.PolyQC++import Prop -- the module that defiens the properties p0, p1, p2, p3, p4+ -- p0 x = x == x+ -- p1 x y z = x + (y + z) == (x + y) + z+ -- p2 x y = x + y == y + x+ -- p3 x = x == negate (negate x)+ -- p4 p = (fst p, snd p) == p++main = do putStrLn "testing p0 ======================================="+ print =<< polyQuickCheck' "Prop" "p0" ["Bool","Int","Double"]+ putStrLn "testing p1 ======================================="+ print =<< polyQuickCheck' "Prop" "p1" ["Bool","Int","Double"]+ putStrLn "testing p2 ======================================="+ print =<< polyQuickCheck' "Prop" "p2" ["Bool","Int","Double"]+ putStrLn "testing p3 ======================================="+ print =<< polyQuickCheck' "Prop" "p3" ["Bool","Int","Double"]+ putStrLn "testing p4 ======================================="+ print =<< polyQuickCheck' "Prop" "p4" ["Bool","Int","Double"]+ return ()++{-++*Main> :t p0+p0 :: (Eq a) => a -> Bool+*Main> :t p1+p1 :: (Num a) => a -> a -> a -> Bool+*Main> :t p2+p2 :: (Num a) => a -> a -> Bool+*Main> :t p3+p3 :: (Num a) => a -> Bool+*Main> :t p4+p4 :: (Eq a, Eq b) => (a, b) -> Bool+*Main> main+testing p0 =======================================+Right ["(\"(Eq Bool) => Bool -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Int) => Int -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Double) => Double -> Bool\",+++ OK, passed 100 tests.+())"]+testing p1 =======================================+Right ["(\"(Num Int) => Int -> Int -> Int -> Bool\",+++ OK, passed 100 tests.+())","(\"(Num Double) => Double -> Double -> Double -> Bool\",*** Failed! Falsifiable (after 9 tests and 2 shrinks): +4.0+-26.0+8.777291602197652+())"]+testing p2 =======================================+Right ["(\"(Num Int) => Int -> Int -> Bool\",+++ OK, passed 100 tests.+())","(\"(Num Double) => Double -> Double -> Bool\",+++ OK, passed 100 tests.+())"]+testing p3 =======================================+Right ["(\"(Num Int) => Int -> Bool\",+++ OK, passed 100 tests.+())","(\"(Num Double) => Double -> Bool\",+++ OK, passed 100 tests.+())"]+testing p4 =======================================+Right ["(\"(Eq Bool, Eq Bool) => (Bool, Bool) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Bool, Eq Int) => (Bool, Int) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Bool, Eq Double) => (Bool, Double) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Int, Eq Bool) => (Int, Bool) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Int, Eq Int) => (Int, Int) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Int, Eq Double) => (Int, Double) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Double, Eq Bool) => (Double, Bool) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Double, Eq Int) => (Double, Int) -> Bool\",+++ OK, passed 100 tests.+())","(\"(Eq Double, Eq Double) => (Double, Double) -> Bool\",+++ OK, passed 100 tests.+())"]++-}
+ test/Prop.hs view
@@ -0,0 +1,12 @@+-- vim: sw=2: ts=2: expandtab:+module Prop where++p0 x = x == x++p1 x y z = x + (y + z) == (x + y) + z++p2 x y = x + y == y + x++p3 x = x == negate (negate x)++p4 p = (fst p, snd p) == p