diff options
author | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 12:30:58 -0500 |
---|---|---|
committer | Stephen Paul Weber <singpolyma@singpolyma.net> | 2012-04-27 12:30:58 -0500 |
commit | 322b24671707c5dc73c51949731f6e5e28948553 (patch) | |
tree | 2d88b696f88d89b5ba9f7b4ef7986cda9faa17bc | |
parent | c45d72cdb08ab9f1f362910c7be9205ce282e934 (diff) |
Autogenerated Arbitrary instances for tests
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | openpgp.cabal | 1 | ||||
-rw-r--r-- | tests/suite.hs | 5 |
4 files changed, 10 insertions, 5 deletions
@@ -1,6 +1,7 @@ | |||
1 | *.[ao] | 1 | *.[ao] |
2 | *.hi | 2 | *.hi |
3 | *.swp* | 3 | *.swp* |
4 | Data/OpenPGP/Arbitrary.hs | ||
4 | verify | 5 | verify |
5 | sign | 6 | sign |
6 | keygen | 7 | keygen |
@@ -19,9 +19,15 @@ debian: debian/control | |||
19 | test: tests/suite | 19 | test: tests/suite |
20 | tests/suite | 20 | tests/suite |
21 | 21 | ||
22 | tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs | 22 | tests/suite: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs Data/OpenPGP/Arbitrary.hs |
23 | ghc --make $(GHCFLAGS) -o $@ $^ | 23 | ghc --make $(GHCFLAGS) -o $@ $^ |
24 | 24 | ||
25 | Data/OpenPGP/Arbitrary.hs: Data/OpenPGP.hs | ||
26 | derive -d Arbitrary -m Data.OpenPGP.Arbitrary -iData.OpenPGP -iTest.QuickCheck -iTest.QuickCheck.Instances -iNumeric -iData.Char -iData.Word -o $@ $^ | ||
27 | -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 $@ | ||
28 | -printf '/return (IssuerPacket/\n-d\ni\n 4 -> do x1 <- fmap (map toUpper . (`showHex` "")) (arbitrary :: Gen Word64)\n.\nw\nq\n' | ed $@ | ||
29 | -printf '/return (UnsupportedSignatureSubpacket/\n-d\n.s/x1/105/g\n.s/x2/x1/g\nw\nq\n' | ed $@ | ||
30 | |||
25 | report.html: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs | 31 | report.html: tests/suite.hs Data/OpenPGP.hs Data/OpenPGP/Internal.hs |
26 | -hlint $(HLINTFLAGS) --report $^ | 32 | -hlint $(HLINTFLAGS) --report $^ |
27 | 33 | ||
diff --git a/openpgp.cabal b/openpgp.cabal index 90cddb4..31ca014 100644 --- a/openpgp.cabal +++ b/openpgp.cabal | |||
@@ -126,6 +126,7 @@ library | |||
126 | 126 | ||
127 | other-modules: | 127 | other-modules: |
128 | Data.OpenPGP.Internal | 128 | Data.OpenPGP.Internal |
129 | Data.OpenPGP.Arbitrary | ||
129 | 130 | ||
130 | build-depends: | 131 | build-depends: |
131 | base == 4.*, | 132 | 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 @@ | |||
2 | import Test.Framework (defaultMain, testGroup, Test) | 2 | import Test.Framework (defaultMain, testGroup, Test) |
3 | import Test.Framework.Providers.HUnit | 3 | import Test.Framework.Providers.HUnit |
4 | import Test.Framework.Providers.QuickCheck2 | 4 | import Test.Framework.Providers.QuickCheck2 |
5 | import Test.QuickCheck | ||
6 | import Test.HUnit hiding (Test) | 5 | import Test.HUnit hiding (Test) |
7 | 6 | ||
8 | import Data.Word | 7 | import Data.Word |
8 | import Data.OpenPGP.Arbitrary () | ||
9 | import qualified Data.OpenPGP as OpenPGP | 9 | import qualified Data.OpenPGP as OpenPGP |
10 | import qualified Data.OpenPGP.Internal as OpenPGP | 10 | import qualified Data.OpenPGP.Internal as OpenPGP |
11 | 11 | ||
@@ -23,9 +23,6 @@ decode' :: (Binary a) => B.ByteString -> a | |||
23 | decode' = decode | 23 | decode' = decode |
24 | #endif | 24 | #endif |
25 | 25 | ||
26 | instance Arbitrary OpenPGP.HashAlgorithm where | ||
27 | arbitrary = elements [OpenPGP.MD5, OpenPGP.SHA1, OpenPGP.SHA256, OpenPGP.SHA384, OpenPGP.SHA512] | ||
28 | |||
29 | testSerialization :: FilePath -> Assertion | 26 | testSerialization :: FilePath -> Assertion |
30 | testSerialization fp = do | 27 | testSerialization fp = do |
31 | bs <- B.readFile $ "tests/data/" ++ fp | 28 | bs <- B.readFile $ "tests/data/" ++ fp |