From 322b24671707c5dc73c51949731f6e5e28948553 Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Fri, 27 Apr 2012 12:30:58 -0500 Subject: Autogenerated Arbitrary instances for tests --- .gitignore | 1 + Makefile | 8 +++++++- openpgp.cabal | 1 + tests/suite.hs | 5 +---- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 41ece44..1156a3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.[ao] *.hi *.swp* +Data/OpenPGP/Arbitrary.hs verify sign keygen diff --git a/Makefile b/Makefile index 2d9b719..105780e 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,15 @@ debian: debian/control test: tests/suite tests/suite -tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs +tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs Data/OpenPGP/Arbitrary.hs ghc --make $(GHCFLAGS) -o $@ $^ +Data/OpenPGP/Arbitrary.hs: Data/OpenPGP.hs + derive -d Arbitrary -m Data.OpenPGP.Arbitrary -iData.OpenPGP -iTest.QuickCheck -iTest.QuickCheck.Instances -iNumeric -iData.Char -iData.Word -o $@ $^ + -printf ',s/SignaturePacket x1 x2 x3 x4 x5 x6 x7 x8 x9)$$/signaturePacket x1 x2 x3 x4 x5 x6 x7 x8)/g\n/signaturePacket/\n-d\nw\nq\n' | ed $@ + -printf '/return (IssuerPacket/\n-d\ni\n 4 -> do x1 <- fmap (map toUpper . (`showHex` "")) (arbitrary :: Gen Word64)\n.\nw\nq\n' | ed $@ + -printf '/return (UnsupportedSignatureSubpacket/\n-d\n.s/x1/105/g\n.s/x2/x1/g\nw\nq\n' | ed $@ + report.html: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs -hlint $(HLINTFLAGS) --report $^ diff --git a/openpgp.cabal b/openpgp.cabal index 90cddb4..31ca014 100644 --- a/openpgp.cabal +++ b/openpgp.cabal @@ -126,6 +126,7 @@ library other-modules: Data.OpenPGP.Internal + Data.OpenPGP.Arbitrary build-depends: base == 4.*, diff --git a/tests/suite.hs b/tests/suite.hs index 9b5e22e..ede60bb 100644 --- a/tests/suite.hs +++ b/tests/suite.hs @@ -2,10 +2,10 @@ import Test.Framework (defaultMain, testGroup, Test) import Test.Framework.Providers.HUnit import Test.Framework.Providers.QuickCheck2 -import Test.QuickCheck import Test.HUnit hiding (Test) import Data.Word +import Data.OpenPGP.Arbitrary () import qualified Data.OpenPGP as OpenPGP import qualified Data.OpenPGP.Internal as OpenPGP @@ -23,9 +23,6 @@ decode' :: (Binary a) => B.ByteString -> a decode' = decode #endif -instance Arbitrary OpenPGP.HashAlgorithm where - arbitrary = elements [OpenPGP.MD5, OpenPGP.SHA1, OpenPGP.SHA256, OpenPGP.SHA384, OpenPGP.SHA512] - testSerialization :: FilePath -> Assertion testSerialization fp = do bs <- B.readFile $ "tests/data/" ++ fp -- cgit v1.2.3