multiarg 0.30.0.4 → 0.30.0.6
raw patch · 8 files changed
+148/−141 lines, 8 filesdep +tastydep +tasty-quickcheckdep +tasty-thdep −barecheckdep −quickpullPVP ok
version bump matches the API change (PVP)
Dependencies added: tasty, tasty-quickcheck, tasty-th
Dependencies removed: barecheck, quickpull
API changes (from Hackage documentation)
Files
- multiarg.cabal +19/−11
- tests/Decrees.hs +0/−26
- tests/Grover/Tests.hs +7/−0
- tests/Multiarg/Maddash/Instances.hs +31/−0
- tests/Multiarg/Maddash/Tests.hs +33/−101
- tests/Multiarg/Types/Instances.hs +42/−0
- tests/Telly/Tests.hs +7/−0
- tests/multiarg-tests.hs +9/−3
multiarg.cabal view
@@ -3,11 +3,11 @@ -- http://www.github.com/massysett/cartel -- -- Script name used to generate: genCabal.hs--- Generated on: 2015-03-19 23:50:01.831337 EDT+-- Generated on: 2015-03-22 11:20:01.157142 EDT -- Cartel library version: 0.14.2.0 name: multiarg-version: 0.30.0.4+version: 0.30.0.6 cabal-version: >= 1.16 license: BSD3 license-file: LICENSE@@ -67,8 +67,9 @@ base >= 4.5.0.0 && < 5 build-depends: QuickCheck >= 2.7 && < 2.9- , quickpull >= 0.4.0.0 && < 0.5- , barecheck >= 0.2.0.6 && < 0.3+ , tasty >= 0.10 && < 0.11+ , tasty-quickcheck >= 0.8 && < 0.9+ , tasty-th >= 0.1 && < 0.2 other-modules: Multiarg Multiarg.Examples@@ -82,11 +83,12 @@ Multiarg.Types Multiarg.Util Multiarg.Vocabulary- Decrees Ernie Grover.Tests Makeopt+ Multiarg.Maddash.Instances Multiarg.Maddash.Tests+ Multiarg.Types.Instances Telly.Tests hs-source-dirs: tests@@ -106,8 +108,9 @@ base >= 4.5.0.0 && < 5 build-depends: QuickCheck >= 2.7 && < 2.9- , quickpull >= 0.4.0.0 && < 0.5- , barecheck >= 0.2.0.6 && < 0.3+ , tasty >= 0.10 && < 0.11+ , tasty-quickcheck >= 0.8 && < 0.9+ , tasty-th >= 0.1 && < 0.2 other-modules: Multiarg Multiarg.Examples@@ -121,11 +124,12 @@ Multiarg.Types Multiarg.Util Multiarg.Vocabulary- Decrees Ernie Grover.Tests Makeopt+ Multiarg.Maddash.Instances Multiarg.Maddash.Tests+ Multiarg.Types.Instances Telly.Tests hs-source-dirs: tests@@ -155,18 +159,22 @@ Multiarg.Types Multiarg.Util Multiarg.Vocabulary- Decrees Ernie Grover.Tests Makeopt+ Multiarg.Maddash.Instances Multiarg.Maddash.Tests+ Multiarg.Types.Instances Telly.Tests hs-source-dirs: tests+ other-extensions:+ TemplateHaskell build-depends: QuickCheck >= 2.7 && < 2.9- , quickpull >= 0.4.0.0 && < 0.5- , barecheck >= 0.2.0.6 && < 0.3+ , tasty >= 0.10 && < 0.11+ , tasty-quickcheck >= 0.8 && < 0.9+ , tasty-th >= 0.1 && < 0.2 Flag programs description: Build sample programs
− tests/Decrees.hs
@@ -1,26 +0,0 @@--- | This module generated by the Quickpull package.--- Quickpull is available at:--- <http://www.github.com/massysett/quickpull>--module Decrees where--import Quickpull-import qualified Grover.Tests-import qualified Multiarg.Maddash.Tests-import qualified Telly.Tests--decrees :: [Decree]-decrees =-- [ Decree ( Meta {modDesc = ModDesc {modPath = "tests/Grover/Tests.hs", modName = ["Grover","Tests"]}, linenum = 123, qName = "prop_ValidGrover"} ) ( Single Grover.Tests.prop_ValidGrover )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Grover/Tests.hs", modName = ["Grover","Tests"]}, linenum = 129, qName = "prop_alwaysTrue"} ) ( Single Grover.Tests.prop_alwaysTrue )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 119, qName = "prop_nonOptWordNotAnOptionIfStateIsReady"} ) ( Single Multiarg.Maddash.Tests.prop_nonOptWordNotAnOptionIfStateIsReady )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 128, qName = "prop_stopperNotAnOptionIfStateIsReady"} ) ( Single Multiarg.Maddash.Tests.prop_stopperNotAnOptionIfStateIsReady )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 136, qName = "prop_singleDashNotAnOptionIfStateIsReady"} ) ( Single Multiarg.Maddash.Tests.prop_singleDashNotAnOptionIfStateIsReady )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 143, qName = "prop_processWordNeverReturnsNotAnOptionOnPending"} ) ( Single Multiarg.Maddash.Tests.prop_processWordNeverReturnsNotAnOptionOnPending )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 152, qName = "prop_processWordNotAnOptionWithReady"} ) ( Single Multiarg.Maddash.Tests.prop_processWordNotAnOptionWithReady )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 202, qName = "prop_optionWithToksResultToksEmpty"} ) ( Single Multiarg.Maddash.Tests.prop_optionWithToksResultToksEmpty )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Multiarg/Maddash/Tests.hs", modName = ["Multiarg","Maddash","Tests"]}, linenum = 204, qName = "prop_optionWithToksResultIsExpected"} ) ( Single Multiarg.Maddash.Tests.prop_optionWithToksResultIsExpected )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Telly/Tests.hs", modName = ["Telly","Tests"]}, linenum = 64, qName = "prop_parseStringsYieldsTellies"} ) ( Single Telly.Tests.prop_parseStringsYieldsTellies )- , Decree ( Meta {modDesc = ModDesc {modPath = "tests/Telly/Tests.hs", modName = ["Telly","Tests"]}, linenum = 70, qName = "prop_parseStringsYieldsNoEndError"} ) ( Single Telly.Tests.prop_parseStringsYieldsNoEndError )- ]
tests/Grover/Tests.hs view
@@ -1,4 +1,5 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures #-}+{-# LANGUAGE TemplateHaskell #-} module Grover.Tests where import Ernie@@ -6,6 +7,12 @@ import Control.Applicative import Test.QuickCheck hiding (Result) import Multiarg.Mode+import Test.Tasty+import Test.Tasty.TH+import Test.Tasty.QuickCheck++tests :: TestTree+tests = $(testGroupGenerator) genGlobal :: Gen Global genGlobal = oneof
+ tests/Multiarg/Maddash/Instances.hs view
@@ -0,0 +1,31 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Multiarg.Maddash.Instances where++import Control.Applicative+import Test.QuickCheck+import Multiarg.Maddash+import Multiarg.Types.Instances ()++instance Arbitrary OptionError where+ arbitrary = oneof+ [ BadOption <$> arbitrary+ , LongArgumentForZeroArgumentOption <$> arbitrary <*> arbitrary+ ]++instance Arbitrary a => Arbitrary (Output a) where+ arbitrary = oneof+ [ Good <$> arbitrary+ , OptionError <$> arbitrary+ ]++instance Arbitrary a => Arbitrary (Pallet a) where+ arbitrary = oneof+ [ return NotAnOption+ , Full <$> arbitrary+ ]++instance Arbitrary a => Arbitrary (State a) where+ arbitrary = oneof+ [ return Ready+ , Pending <$> arbitrary <*> arbitrary+ ]
tests/Multiarg/Maddash/Tests.hs view
@@ -1,59 +1,25 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures #-}+{-# LANGUAGE TemplateHaskell #-} module Multiarg.Maddash.Tests where import Control.Applicative import Multiarg.Types import Multiarg.Maddash-import Test.QuickCheck- ( Gen, Arbitrary(..), CoArbitrary(..),- suchThat, listOf, oneof, forAll, Property,- (==>), choose, vectorOf )-import Prelude.Generators (function1, function2, function3)-import qualified Prelude.Generators as G import Makeopt+import Test.QuickCheck+import Test.Tasty+import Test.Tasty.TH+import Test.Tasty.QuickCheck+import Multiarg.Types.Instances ()+import Multiarg.Maddash.Instances ()+import Multiarg.Types.Instances () +tests :: TestTree+tests = $(testGroupGenerator)+ genInt :: Gen Int genInt = arbitrary -genStringF1 :: Gen (String -> Int)-genStringF1 = function1 coarbitrary arbitrary--genStringF2 :: Gen (String -> String -> Int)-genStringF2 = function2 coarbitrary coarbitrary arbitrary--genStringF3 :: Gen (String -> String -> String -> Int)-genStringF3 = function3 coarbitrary coarbitrary coarbitrary arbitrary--genShortName :: Gen ShortName-genShortName = do- c <- arbitrary- case shortName c of- Nothing -> genShortName- Just n -> return n--genLongName :: Gen LongName-genLongName = do- c1 <- arbitrary `suchThat` (\c -> c /= '-' && c /= '=')- cs <- listOf (arbitrary `suchThat` (/= '='))- case longName (c1 : cs) of- Nothing -> error $ "could not generate long name: " ++ (c1:cs)- Just n -> return n--genOptName :: Gen OptName-genOptName = fmap OptName $ G.either genShortName genLongName--genArgSpec :: Gen (ArgSpec Int)-genArgSpec = oneof- [ fmap ZeroArg arbitrary- , fmap OneArg (function1 coarbitrary arbitrary)- , fmap TwoArg (function2 coarbitrary coarbitrary arbitrary)- , fmap ThreeArg (function3 coarbitrary coarbitrary coarbitrary- arbitrary)- ]--genWord :: Gen Word-genWord = fmap Word arbitrary- singleDash :: Word singleDash = Word "-" @@ -70,91 +36,57 @@ return $ Word (c1 : cs) ] -coaWord :: Word -> Gen b -> Gen b-coaWord (Word s) = coarbitrary s--genOptArg :: Gen OptArg-genOptArg = fmap OptArg arbitrary--genOptionError :: Gen OptionError-genOptionError = oneof- [ fmap BadOption genOptName- , LongArgumentForZeroArgumentOption <$> genLongName <*> genOptArg- ]--genOutput :: Gen (Output Int)-genOutput = oneof- [ fmap Good arbitrary- , fmap OptionError genOptionError- ]--genPallet :: Gen (Pallet Int)-genPallet = oneof- [ return NotAnOption- , fmap Full $ listOf genOutput- ]--genPending :: Gen (State Int)-genPending = Pending <$> genOptName <*> genF- where- genF = function1 coaWord- ((,) <$> listOf genOutput <*> genState)--genState :: Gen (State Int)-genState = oneof- [ return Ready- , genPending- ]--genShortArgSpecs :: Gen [(ShortName, ArgSpec Int)]-genShortArgSpecs = listOf ((,) <$> genShortName <*> genArgSpec)--genLongArgSpecs :: Gen [(LongName, ArgSpec Int)]-genLongArgSpecs = listOf ((,) <$> genLongName <*> genArgSpec)+genPending :: Arbitrary a => Gen (State a)+genPending = Pending <$> arbitrary <*> arbitrary -- * Properties -- | Non-option token always returns NotAnOption if State is Ready prop_nonOptWordNotAnOptionIfStateIsReady :: Property prop_nonOptWordNotAnOptionIfStateIsReady =- forAll genShortArgSpecs $ \shorts ->- forAll genLongArgSpecs $ \longs ->+ forAll arbitrary $ \shorts ->+ forAll arbitrary $ \longs -> forAll genNonOptWord $ \token -> let (pallet, _) = processWord shorts longs Ready token+ _types = shorts :: [(ShortName, ArgSpec Int)] in pallet == NotAnOption -- | Stopper always returns NotAnOption if State is Ready prop_stopperNotAnOptionIfStateIsReady :: Property prop_stopperNotAnOptionIfStateIsReady =- forAll genShortArgSpecs $ \shorts ->- forAll genLongArgSpecs $ \longs ->+ forAll arbitrary $ \shorts ->+ forAll arbitrary $ \longs -> let (pallet, _) = processWord shorts longs Ready stopper+ _types = shorts :: [(ShortName, ArgSpec Int)] in pallet == NotAnOption -- | Single dash always returns NotAnOption if State is Ready prop_singleDashNotAnOptionIfStateIsReady :: Property prop_singleDashNotAnOptionIfStateIsReady =- forAll genShortArgSpecs $ \shorts ->- forAll genLongArgSpecs $ \longs ->+ forAll arbitrary $ \shorts ->+ forAll arbitrary $ \longs -> let (pallet, _) = processWord shorts longs Ready singleDash+ _types = shorts :: [(ShortName, ArgSpec Int)] in pallet == NotAnOption -- | processWord never returns NotAnOption when input is Pending prop_processWordNeverReturnsNotAnOptionOnPending =- forAll genShortArgSpecs $ \shorts ->- forAll genLongArgSpecs $ \longs ->+ forAll arbitrary $ \shorts ->+ forAll arbitrary $ \longs -> forAll genPending $ \state ->- forAll genWord $ \token ->+ forAll arbitrary $ \token -> let (pallet, _) = processWord shorts longs state token+ _types = shorts :: [(ShortName, ArgSpec Int)] in pallet /= NotAnOption -- | NotAnOption is always returned with Ready prop_processWordNotAnOptionWithReady =- forAll genShortArgSpecs $ \shorts ->- forAll genLongArgSpecs $ \longs ->- forAll genState $ \state ->- forAll genWord $ \token ->+ forAll arbitrary $ \shorts ->+ forAll arbitrary $ \longs ->+ forAll arbitrary $ \state ->+ forAll arbitrary $ \token -> let (pallet, state') = processWord shorts longs state token+ _types = shorts :: [(ShortName, ArgSpec Int)] in pallet == NotAnOption ==> isReady state' pickOne :: [a] -> Gen a@@ -174,8 +106,8 @@ instance Arbitrary OptionWithToks where arbitrary = do- OptName on <- genOptName- as <- genArgSpec+ OptName on <- arbitrary+ as <- arbitrary (args, expected) <- case as of ZeroArg a -> return ([], a) OneArg f -> do
+ tests/Multiarg/Types/Instances.hs view
@@ -0,0 +1,42 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+module Multiarg.Types.Instances where++import Control.Applicative+import Test.QuickCheck+import Multiarg.Types++instance Arbitrary a => Arbitrary (ArgSpec a) where+ arbitrary = oneof+ [ ZeroArg <$> arbitrary+ , OneArg <$> arbitrary+ , TwoArg <$> arbitrary+ , ThreeArg <$> arbitrary+ ]++instance Arbitrary ShortName where+ arbitrary = do+ c <- arbitrary+ case shortName c of+ Nothing -> arbitrary+ Just n -> return n++instance Arbitrary LongName where+ arbitrary = do+ c1 <- arbitrary `suchThat` (\c -> c /= '-' && c /= '=')+ cs <- listOf (arbitrary `suchThat` (/= '='))+ case longName (c1 : cs) of+ Nothing -> error $ "could not generate long name: " ++ (c1:cs)+ Just n -> return n++instance Arbitrary OptName where+ arbitrary = fmap OptName arbitrary++instance Arbitrary Word where+ arbitrary = Word <$> arbitrary++instance CoArbitrary Word where+ coarbitrary (Word s) = coarbitrary s++instance Arbitrary OptArg where+ arbitrary = OptArg <$> arbitrary+
tests/Telly/Tests.hs view
@@ -1,4 +1,5 @@ {-# OPTIONS_GHC -fno-warn-missing-signatures #-}+{-# LANGUAGE TemplateHaskell #-} module Telly.Tests where import Multiarg.Examples.Telly@@ -6,6 +7,12 @@ import Control.Applicative import Ernie import Multiarg.Internal+import Test.Tasty+import Test.Tasty.TH+import Test.Tasty.QuickCheck++tests :: TestTree+tests = $(testGroupGenerator) -- | Generates any option. option :: Gen Telly
tests/multiarg-tests.hs view
@@ -1,7 +1,13 @@ module Main where -import Quickpull-import Decrees+import qualified Multiarg.Maddash.Tests+import qualified Grover.Tests+import qualified Telly.Tests+import Test.Tasty main :: IO ()-main = defaultMain decrees+main = defaultMain $ testGroup "all properties"+ [ Multiarg.Maddash.Tests.tests+ , Grover.Tests.tests+ , Telly.Tests.tests+ ]