fishfood 0.0.1.5 → 0.0.1.6
raw patch · 20 files changed
+271/−241 lines, 20 filesdep +data-defaultdep ~toolshedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: data-default
Dependency ranges changed: toolshed
API changes (from Hackage documentation)
- FishFood.Data.CommandOptions: instance ToolShed.Defaultable.Defaultable (FishFood.Data.CommandOptions.CommandOptions ratio)
- FishFood.Data.Verbosity: instance ToolShed.Defaultable.Defaultable Distribution.Verbosity.Verbosity
+ FishFood.Data.CommandOptions: instance Data.Default.Class.Default (FishFood.Data.CommandOptions.CommandOptions ratio)
+ FishFood.Data.Verbosity: instance Data.Default.Class.Default Distribution.Verbosity.Verbosity
Files
- .ghci +1/−0
- README.markdown +11/−8
- changelog.Debian +1/−1
- changelog.markdown +42/−22
- copyright +1/−1
- debian/DEBIAN/control +2/−2
- fishfood.cabal +22/−15
- fishfood.spec +3/−3
- man/man1/fishfood.1 +11/−7
- src-exe/Main.hs +8/−8
- src-lib/FishFood/Data/CommandOptions.hs +5/−5
- src-lib/FishFood/Data/Verbosity.hs +4/−4
- src-lib/FishFood/Profiler.hs +3/−3
- src-test/FishFood/Test/Data/CommandOptions.hs +0/−65
- src-test/FishFood/Test/Data/Verbosity.hs +0/−31
- src-test/FishFood/Test/Profiler.hs +0/−58
- src-test/FishFood/Test/QuickCheck/Data/CommandOptions.hs +65/−0
- src-test/FishFood/Test/QuickCheck/Data/Verbosity.hs +31/−0
- src-test/FishFood/Test/QuickCheck/Profiler.hs +58/−0
- src-test/Main.hs +3/−8
+ .ghci view
@@ -0,0 +1,1 @@+:set -isrc-lib:src-exe:src-test:dist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
README.markdown view
@@ -1,29 +1,32 @@-# **FishFood**.+# **FishFood** -This is **FishFood**, an application which determines the distribution in sizes of the specified files.+[](https://hackage.haskell.org/package/fishfood) [](https://travis-ci.org/functionalley/FishFood) +This is "**FishFood**", an application which determines the distribution in sizes of the specified files.+ ## Installation It can be built and installed using [Cabal](https://www.haskell.org/cabal/users-guide/installing-packages.html). ## Documentation -The directory **man/** contains the documentation.+The directory "**man/**" contains the documentation. ## License -For information on copying and distributing this package, see the file **LICENSE** in this directory.+For information on copying and distributing this package, see the file "**LICENSE**" in this directory. ## Bug-reporting -Bug-reports should be emailed to <fishfood *at* functionalley *dot* eu>.+Bug-reports should be emailed to <fishfood@functionalley.eu>. ## Testing The test-suite can be run using:- cabal configure --enable-tests- cabal build- cabal test --show-details=always++ cabal configure --enable-tests;+ cabal build;+ cabal test --show-details=always; ## Author
changelog.Debian view
@@ -2,4 +2,4 @@ * New release. - -- Alistair Ward <fishfood at functionalley dot eu> Tue, 23 Jul 2013 17:00:00 +0000+ -- Alistair Ward <fishfood@functionalley.eu> Tue, 23 Jul 2013 17:00:00 +0000
changelog.markdown view
@@ -1,31 +1,51 @@-# 2013-07-16 Dr. Alistair Ward <fishfood at functionalley dot eu>+# 2013-07-16 Dr. Alistair Ward <fishfood@functionalley.eu> ## 0.0.0.1- * First version of the package.+* First version of the package.+ ## 0.0.0.2- * Added **man/man1/fishfood.1** & *.spec*-file to the distribution.+* Added file "**man/man1/fishfood.1**" & *.spec*-file to the distribution.+ ## 0.0.1.0- * Migrated all but the I/O, from **Main** to a new module **FishFood.Profiler**.- * Added module **FishFood.Test**, containing **Test.QuickCheck**-implementation.- * Added Command-line options; **--deriveProbabilityMassFunction**, **--binSizeRatio**, **--runQuickChecks**.+* Migrated all but the I/O, from module "**Main**" to a new module "**FishFood.Profiler**".+* Added module "**FishFood.Test**", containing **Test.QuickCheck**-implementation.+* Added Command-line options;+ + "**--deriveProbabilityMassFunction**",+ + "**--binSizeRatio**",+ + "**--runQuickChecks**".+ ## 0.0.1.1- * Added files to build *.deb* to the *.cabal*-file.+* Added files to build *.deb* to the *.cabal*-file.+ ## 0.0.1.2- * Added **--runQuickChecks** to **man/man1/fishfood.1** & corrected typo.- * Improved the syntax of **verbosity** in the usage-message.- * Tested with **haskell-platform-2013.2.0.0**.+* Added flag "**--runQuickChecks**" to file "**man/man1/fishfood.1**" & corrected typo.+* Improved the syntax of flag "**--verbosity**" in the usage-message.+* Tested with **haskell-platform-2013.2.0.0**.+ ## 0.0.1.3- * In module **FishFood.Data.File**, replaced `Control.Exception.throw` with `Control.Exception.throwIO`.- * Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between **Control.Applicative** & **Prelude** which (from **base-4.8**) also exports this symbol, or hid the symbol when importing the **Prelude**..- * In module **Main**, redirected version-message to stderr.+* In module "**FishFood.Data.File**", replaced `Control.Exception.throw` with `Control.Exception.throwIO`.+* Either replaced instances of `(<$>)` with `fmap` to avoid ambiguity between modules "**Control.Applicative**" & "**Prelude**" which (from package "**base-4.8**") also exports this symbol, or hid the symbol when importing the module "**Prelude**".+* In module "**Main**", redirected version-message to stderr.+ ## 0.0.1.4- * Added the compiler to the output returned for the command-line option **version**.- * In module **FishFood.Data.File.hs**, replaced the use of the package **unix** with the package **directory**, for compatibility with Windows.+* Added the compiler to the output returned for the command-line option "**--version**".+* In module "**FishFood.Data.File.hs**", replaced the use of the package "**unix**" with the package "**directory**", for compatibility with **Windows**.+ ## 0.0.1.5- * Added **Default-language**-specification to the *.cabal*-file.- * Added file **README.markdown**.- * Converted this file to markdown-format.- * Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.- * Moved the entry-point to the test-suite from **Main.hs** to **Test.hs**, both to integrate with **cabal** & to minimise the dependencies of the executable.- * Partitioned the source-files into **src-lib**, **src-exe**, & **src-test** directories, & referenced them individually from the *.cabal*-file to avoid repeated compilation.- * Used **CPP** to control the import of symbols from **Control.Applicative**.+* Added "**Default-language**"-specification to the *.cabal*-file.+* Added file "**README.markdown**".+* Converted this file to markdown-format.+* Replaced `System.Exit.exitWith System.Exit.ExitSuccess` with `System.Exit.exitSuccess`.+* Moved the entry-point to the test-suite from module "**Main**" to "**Test**", both to integrate with **cabal** & to minimise the dependencies of the executable.+* Partitioned the source-files into directories "**src-lib**", "**src-exe**", & "**src-test**", & referenced them individually from the *.cabal*-file to avoid repeated compilation.+* Used **CPP** to control the import of symbols from **Control.Applicative**.++## 0.0.1.6+* Corrected the markdown-syntax in this file.+* Amended to call "**error**" rather than "**Control.Monad.fail**", since the **String**-argument for the latter is discarded in **Monad**-implementations other than **IO**.+* Uploaded to [GitHub](https://github.com/functionalley/FishFood.git).+* Simplified file **src-test/Main.hs**.+* Added file **.travis.yml** to control testing by <https://docs.travis-ci.com>.+* Added file **.ghci**.+* Replaced use of module **ToolShed.Defaultable** with **Data.Default**.+* Tested with **ghc-8.0.1**.
copyright view
@@ -1,5 +1,5 @@ Author:- Dr. Alistair Ward <fishfood at functionalley dot eu>.+ Dr. Alistair Ward <fishfood@functionalley.eu>. Copyright: Copyright (C) 2013 Dr. Alistair Ward. All Rights Reserved.
debian/DEBIAN/control view
@@ -1,11 +1,11 @@ Package: fishfood-Version: 0.0.1.5-1+Version: 0.0.1.6-1 Section: utils Priority: optional Architecture: amd64 Depends: libc6 Installed-size: 2082-Maintainer: Dr. Alistair Ward <fishfood at functionalley dot eu>+Maintainer: Dr. Alistair Ward <fishfood@functionalley.eu> Provides: Homepage: http://functionalley.eu Description: Counts the number of files in a set of bins, each of which holds only those files which fall within a specific size-interval.
fishfood.cabal view
@@ -14,7 +14,7 @@ -- along with FishFood. If not, see <http://www.gnu.org/licenses/>. Name: fishfood-Version: 0.0.1.5+Version: 0.0.1.6 Cabal-version: >= 1.10 Copyright: (C) 2013-2015 Dr. Alistair Ward License: GPL@@ -25,13 +25,14 @@ Build-type: Simple Description: Counts the number of files in a set of bins, each of which holds only those files which fall within a specific size-interval. Category: Utils-Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10+Tested-with: GHC == 7.4, GHC == 7.6, GHC == 7.8, GHC == 7.10.1, GHC == 8.0.1 Homepage: http://functionalley.eu-Maintainer: mailto <colon> fishfood <at> functionalley <dot> eu-Bug-reports: mailto <colon> fishfood <at> functionalley <dot> eu+Maintainer: mailto:fishfood@functionalley.eu+Bug-reports: mailto:fishfood@functionalley.eu -- None of these files are needed at run-time. Extra-source-files:+ .ghci changelog.markdown changelog.Debian copyright@@ -40,6 +41,10 @@ man/man1/fishfood.1 README.markdown +source-repository head+ type: git+ location: https://github.com/functionalley/FishFood+ -- Enable using: 'cabal configure -f llvm'. flag llvm Description: Whether the 'llvm' compiler-backend has been installed and is required for code-generation.@@ -61,15 +66,16 @@ base == 4.*, Cabal >= 1.10, containers,+ data-default, directory, factory >= 0.2.0.5, mtl,- toolshed >= 0.16+ toolshed >= 0.17 if impl(ghc >= 7.4.1)- GHC-prof-options: -prof -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs else- GHC-prof-options: -prof -auto-all -caf-all+ GHC-prof-options: -auto-all -caf-all if impl(ghc >= 7.0) && flag(llvm) GHC-options: -fllvm@@ -83,14 +89,15 @@ Build-depends: base == 4.*, Cabal >= 1.10,+ data-default, fishfood, mtl,- toolshed >= 0.16+ toolshed >= 0.17 if impl(ghc >= 7.4.1)- GHC-prof-options: -prof -fprof-auto -fprof-cafs+ GHC-prof-options: -fprof-auto -fprof-cafs else- GHC-prof-options: -prof -auto-all -caf-all+ GHC-prof-options: -auto-all -caf-all if impl(ghc >= 7.0) GHC-options: -rtsopts@@ -98,7 +105,7 @@ if flag(llvm) GHC-options: -fllvm -Test-Suite quickCheck+Test-Suite test Default-language: Haskell2010 GHC-options: -Wall -fno-warn-tabs Hs-source-dirs: src-test@@ -107,9 +114,9 @@ -- Required for 'cabal sdist'. Other-modules:- FishFood.Test.Data.CommandOptions- FishFood.Test.Data.Verbosity- FishFood.Test.Profiler+ FishFood.Test.QuickCheck.Data.CommandOptions+ FishFood.Test.QuickCheck.Data.Verbosity+ FishFood.Test.QuickCheck.Profiler Build-depends: base == 4.*,@@ -118,5 +125,5 @@ fishfood, mtl, QuickCheck,- toolshed >= 0.16+ toolshed >= 0.17
fishfood.spec view
@@ -21,7 +21,7 @@ Summary: Calculates file-size frequency-distribution. Name: fishfood-Version: 0.0.1.5+Version: 0.0.1.6 Release: 1 License: GPLv3 # From '/usr/share/doc/packages/rpm/GROUPS'.@@ -35,7 +35,7 @@ Counts the number of files in a set of bins, each of which holds only those files which fall within a specific size-interval. %prep-# NB: CWD has changed to %_builddir+# N.B.: CWD has changed to %_builddir echo 'package="%package", prefix="%prefix", _builddir="%_builddir", buildroot="%buildroot"' (cd $OLDPWD && cabal sdist) && tar -zxf $OLDPWD/dist/%tarBall # Make a source-distribution & unpack it into the build-directory. cd '%package/' && cabal configure --user --prefix='%prefix' --docdir='%_docdir' # Tell cabal to use the user's personal package-database, to generate an appropriate "Paths" module, & where to place the documentation.@@ -62,6 +62,6 @@ %attr(0644, root, root) %doc %_mandir/man1/%name.1.gz %changelog-* Tue Jul 16 2013 Alistair Ward <fishfood at functionalley dot eu> 0.0.0.2-1+* Tue Jul 16 2013 Alistair Ward <fishfood@functionalley.eu> 0.0.0.2-1 First cut.
man/man1/fishfood.1 view
@@ -136,7 +136,7 @@ Written by Dr. Alistair Ward. .SH BUGS .SS "REPORTING BUGS"-Report bugs to <\fBfishfood\fR \fIat\fR \fBfunctionalley\fR \fIdot\fR \fBeu\fR>.+Report bugs to <\fBfishfood@functionalley.eu\fR>. .SH COPYRIGHT Copyright \(co 2013-2015 Dr. Alistair Ward .PP@@ -149,17 +149,21 @@ .IP \(bu Home-page: \fBhttp://functionalley.eu\fR .IP \(bu-.B http://en.wikipedia.org/wiki/Interval_(mathematics)+.B http://hackage.haskell.org/package/fishfood .IP \(bu-.B http://en.wikipedia.org/wiki/Standard_deviation+.B https://github.com/functionalley/FishFood .IP \(bu-.B http://en.wikipedia.org/wiki/Frequency_distribution+.B https://en.wikipedia.org/wiki/Interval_(mathematics) .IP \(bu-.B http://en.wikipedia.org/wiki/Geometric_distribution+.B https://en.wikipedia.org/wiki/Standard_deviation .IP \(bu-.B http://en.wikipedia.org/wiki/Log-normal_distribution+.B https://en.wikipedia.org/wiki/Frequency_distribution .IP \(bu-.B http://en.wikipedia.org/wiki/Probability_mass_function+.B https://en.wikipedia.org/wiki/Geometric_distribution+.IP \(bu+.B https://en.wikipedia.org/wiki/Log-normal_distribution+.IP \(bu+.B https://en.wikipedia.org/wiki/Probability_mass_function .IP \(bu Source-documentation is generated by "\fBHaddock\fR", & is available in the distribution. .IP \(bu
src-exe/Main.hs view
@@ -31,6 +31,7 @@ import qualified Control.Monad import qualified Control.Monad.Writer+import qualified Data.Default import qualified Data.List import qualified Data.Maybe import qualified Data.Version@@ -49,7 +50,6 @@ import qualified System.IO import qualified System.IO.Error import qualified ToolShed.Data.List-import qualified ToolShed.Defaultable import qualified ToolShed.SelfValidate #if !MIN_VERSION_base(4,8,0)@@ -94,7 +94,7 @@ let defaultCommandOptions :: CommandOptions- defaultCommandOptions = ToolShed.Defaultable.defaultValue+ defaultCommandOptions = Data.Default.def optDescrList :: [G.OptDescr CommandLineAction] optDescrList = [@@ -124,7 +124,7 @@ printVersion, printUsage :: IO CommandOptions printVersion = System.IO.hPutStrLn System.IO.stderr (- Distribution.Text.display packageIdentifier ++ "\n\nCompiled by " ++ show compiler ++ ".\n\nCopyright (C) 2013-2015 " ++ author ++ ".\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions.\n\nWritten by " ++ author ++ "."+ showString (Distribution.Text.display packageIdentifier) . showString "\nCompiled by " . shows compiler . showString ".\nWritten by " . shows author . showString ".\nCopyright (C) 2013-2015 " $ showString author ".\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it under certain conditions." ) >> System.Exit.exitSuccess where packageIdentifier :: Distribution.Package.PackageIdentifier packageIdentifier = Distribution.Package.PackageIdentifier {@@ -142,12 +142,12 @@ case G.getOpt G.RequireOrder optDescrList args of (commandLineActions, nonOptions, [{-errors-}]) -> do- commandOptions <- Data.List.foldl' (>>=) (return {-to IO-monad-} ToolShed.Defaultable.defaultValue) commandLineActions+ commandOptions <- Data.List.foldl' (>>=) (return {-to IO-monad-} Data.Default.def) commandLineActions if not $ ToolShed.SelfValidate.isValid commandOptions- then fail $ ToolShed.SelfValidate.getFirstError commandOptions+ then error $ ToolShed.SelfValidate.getFirstError commandOptions else if null nonOptions- then fail "zero file-paths specified"+ then error "zero file-paths specified." else let standardInputProxy = "-" in do@@ -164,7 +164,7 @@ filePaths <- (filter (/= standardInputProxy) nonOptions ++) <$> getFilePaths if null filePaths- then fail "zero file-paths"+ then error "zero file-paths." else return filePaths else {-real fileNames-} return {-to IO-monad-} nonOptions @@ -172,7 +172,7 @@ (fileSizeDistribution, statistics) <- Control.Monad.Writer.runWriter . Profiler.calculateFileSizeDistribution commandOptions <$> mapM Data.File.findSize (Data.List.nub filePaths) - Control.Monad.when (Data.CommandOptions.getVerbosity commandOptions > ToolShed.Defaultable.defaultValue) $ mapM_ (System.IO.hPutStrLn System.IO.stderr) statistics+ Control.Monad.when (Data.CommandOptions.getVerbosity commandOptions > Data.Default.def) $ mapM_ (System.IO.hPutStrLn System.IO.stderr) statistics putStrLn $ Profiler.formatFileSizeDistribution commandOptions fileSizeDistribution (_, _, errors) -> System.IO.Error.ioError . System.IO.Error.userError $ concatMap init {-chop-} errors
src-lib/FishFood/Data/CommandOptions.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2013 Dr. Alistair Ward+ Copyright (C) 2013-2015 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -39,17 +39,17 @@ getVerbosity ), -- * Functions--- ** Constructors+-- ** Constructor mkCommandOptions, -- ** Mutators setBinSizeIncrement, setBinSizeRatio ) where +import qualified Data.Default import qualified Data.Maybe import qualified Distribution.Verbosity import qualified FishFood.Data.File as Data.File-import qualified ToolShed.Defaultable import qualified ToolShed.SelfValidate -- | Either an arithmetic size-increase for which there's a default, or a geometric size-ratio.@@ -63,8 +63,8 @@ getVerbosity :: Distribution.Verbosity.Verbosity -- ^ The threshold for ancillary information-output. } deriving Show -instance ToolShed.Defaultable.Defaultable (CommandOptions ratio) where- defaultValue = MkCommandOptions {+instance Data.Default.Default (CommandOptions ratio) where+ def = MkCommandOptions { getBinSizeDelta = Left Nothing, -- Interpreted as one standard-deviation. getDeriveProbabilityMassFunction = False, getNDecimalDigits = 3,
src-lib/FishFood/Data/Verbosity.hs view
@@ -1,6 +1,6 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-- Copyright (C) 2013 Dr. Alistair Ward+ Copyright (C) 2013-2015 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -26,11 +26,11 @@ range ) where +import qualified Data.Default import qualified Distribution.Verbosity-import qualified ToolShed.Defaultable -instance ToolShed.Defaultable.Defaultable Distribution.Verbosity.Verbosity where- defaultValue = Distribution.Verbosity.normal+instance Data.Default.Default Distribution.Verbosity.Verbosity where+ def = Distribution.Verbosity.normal -- | The constant complete range of values. range :: [Distribution.Verbosity.Verbosity]
src-lib/FishFood/Profiler.hs view
@@ -1,5 +1,5 @@ {-- Copyright (C) 2013 Dr. Alistair Ward+ Copyright (C) 2013-2015 Dr. Alistair Ward This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -36,6 +36,7 @@ import Control.Arrow((&&&),(***)) import qualified Control.Monad.Writer+import qualified Data.Default import qualified Data.List import qualified Data.Map import qualified Data.Maybe@@ -43,7 +44,6 @@ import qualified FishFood.Data.File as Data.File import FishFood.Data.Verbosity() import qualified Text.Printf-import qualified ToolShed.Defaultable -- | Define a type to represent the fractional closed unit-interval. type Probability = Double@@ -123,7 +123,7 @@ formatFileSizeDistribution commandOptions = Data.List.intercalate "\n" . map ( \(fileSize, value) -> fileSize ++ " " ++ value ) . (- if Data.CommandOptions.getVerbosity commandOptions > ToolShed.Defaultable.defaultValue+ if Data.CommandOptions.getVerbosity commandOptions > Data.Default.def then ( [ (
− src-test/FishFood/Test/Data/CommandOptions.hs
@@ -1,65 +0,0 @@-{-# LANGUAGE CPP #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-- Copyright (C) 2013-2015 Dr. Alistair Ward-- This program is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Data.CommandOptions.CommandOptions'.--}--module FishFood.Test.Data.CommandOptions(--- * Types--- ** Type-synonyms- CommandOptions-) where--import qualified Test.QuickCheck-import qualified FishFood.Data.CommandOptions as Data.CommandOptions-import FishFood.Test.Data.Verbosity()--#if !MIN_VERSION_base(4,8,0)-import Control.Applicative((<$>), (<*>))-#endif--instance (- Enum ratio,- Fractional ratio,- Ord ratio,- Show ratio,- Test.QuickCheck.Arbitrary ratio- ) => Test.QuickCheck.Arbitrary (Data.CommandOptions.CommandOptions ratio) where- arbitrary = do- deriveProbabilityMassFunction <- Test.QuickCheck.arbitrary-- Data.CommandOptions.mkCommandOptions <$> (- either (- Left . (succ . abs <$> {-into Maybe-monad-})- ) (- Right . (+ recip 1000000) . succ . abs- ) <$> Test.QuickCheck.arbitrary {-binSizeDelta-}- ) <*> return {-to Gen-monad-} deriveProbabilityMassFunction <*> (- max (- if deriveProbabilityMassFunction then 1 else 0- ) . (- `mod` 15 {-maximum permissible-}- ) <$> Test.QuickCheck.arbitrary {-nDecimalDigits-}- ) <*> Test.QuickCheck.arbitrary {-verbosity-}---- | Defines a concrete type for testing.-type CommandOptions = Data.CommandOptions.CommandOptions Double-
− src-test/FishFood/Test/Data/Verbosity.hs
@@ -1,31 +0,0 @@-{-# OPTIONS_GHC -fno-warn-orphans #-}-{-- Copyright (C) 2013 Dr. Alistair Ward-- This program is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Distribution.Verbosity.Verbosity'.--}--module FishFood.Test.Data.Verbosity() where--import qualified Distribution.Verbosity-import qualified FishFood.Data.Verbosity as Data.Verbosity-import qualified Test.QuickCheck--instance Test.QuickCheck.Arbitrary Distribution.Verbosity.Verbosity where- arbitrary = Test.QuickCheck.elements Data.Verbosity.range
− src-test/FishFood/Test/Profiler.hs
@@ -1,58 +0,0 @@-{-- Copyright (C) 2013-2015 Dr. Alistair Ward-- This program is free software: you can redistribute it and/or modify- it under the terms of the GNU General Public License as published by- the Free Software Foundation, either version 3 of the License, or- (at your option) any later version.-- This program is distributed in the hope that it will be useful,- but WITHOUT ANY WARRANTY; without even the implied warranty of- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- GNU General Public License for more details.-- You should have received a copy of the GNU General Public License- along with this program. If not, see <http://www.gnu.org/licenses/>.--}-{- |- [@AUTHOR@] Dr. Alistair Ward-- [@DESCRIPTION@] Defines /QuickCheck/-properties for 'Profiler'.--}--module FishFood.Test.Profiler(--- * Constants- results-) where--import qualified Control.Monad.Writer-import qualified Data.Either-import qualified Data.Set-import qualified FishFood.Data.CommandOptions as Data.CommandOptions-import qualified FishFood.Data.File as Data.File-import qualified FishFood.Profiler as Profiler-import qualified FishFood.Test.Data.CommandOptions as Test.Data.CommandOptions-import qualified Test.QuickCheck-import Test.QuickCheck((==>))-import qualified ToolShed.SelfValidate---- | The constant test-results for this data-type.-results :: IO [Test.QuickCheck.Result]-results = mapM Test.QuickCheck.quickCheckResult [prop_calculateProbabilityMassFunction, prop_calculateFileSizeFrequencyDistribution, prop_attendance] where- prop_calculateProbabilityMassFunction, prop_calculateFileSizeFrequencyDistribution, prop_attendance :: Test.Data.CommandOptions.CommandOptions -> [Data.File.FileSize] -> Test.QuickCheck.Property- prop_calculateProbabilityMassFunction commandOptions fileSizes = not (null fileSizes) && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_calculateProbabilityMassFunction" . (<= recip 1000000) . (+ negate 1) . sum . Data.Either.rights {-probabilities-} . map Profiler.getValue . fst {-distribution-} . Control.Monad.Writer.runWriter . Profiler.calculateFileSizeDistribution commandOptions' $ map abs fileSizes where- commandOptions' = commandOptions { Data.CommandOptions.getDeriveProbabilityMassFunction = True }-- prop_calculateFileSizeFrequencyDistribution commandOptions fileSizes = not (null fileSizes) && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_calculateFileSizeFrequencyDistribution" . (== length fileSizes) . sum . Data.Either.lefts {-frequency-} . map Profiler.getValue . fst {-distribution-} . Control.Monad.Writer.runWriter . Profiler.calculateFileSizeDistribution commandOptions' $ map abs fileSizes where- commandOptions' = commandOptions { Data.CommandOptions.getDeriveProbabilityMassFunction = False }-- prop_attendance commandOptions fileSizes = not (null fileSizes') && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_attendance" . (- == Data.Set.fromList fileSizes'- ) . Data.Set.fromList . map Profiler.getFileSize . filter (- (/= 0) . either fromIntegral id . Profiler.getValue -- Remove file-sizes which match zero actual files.- ) . fst {-distribution-} . Control.Monad.Writer.runWriter $ Profiler.calculateFileSizeDistribution commandOptions' fileSizes' where- fileSizes' = map abs fileSizes-- commandOptions' :: Test.Data.CommandOptions.CommandOptions- commandOptions' = Data.CommandOptions.setBinSizeIncrement 1 commandOptions-
+ src-test/FishFood/Test/QuickCheck/Data/CommandOptions.hs view
@@ -0,0 +1,65 @@+{-# LANGUAGE CPP #-}+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+ Copyright (C) 2013-2015 Dr. Alistair Ward++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Data.CommandOptions.CommandOptions'.+-}++module FishFood.Test.QuickCheck.Data.CommandOptions(+-- * Types+-- ** Type-synonyms+ CommandOptions+) where++import qualified Test.QuickCheck+import qualified FishFood.Data.CommandOptions as Data.CommandOptions+import FishFood.Test.QuickCheck.Data.Verbosity()++#if !MIN_VERSION_base(4,8,0)+import Control.Applicative((<$>), (<*>))+#endif++instance (+ Enum ratio,+ Fractional ratio,+ Ord ratio,+ Show ratio,+ Test.QuickCheck.Arbitrary ratio+ ) => Test.QuickCheck.Arbitrary (Data.CommandOptions.CommandOptions ratio) where+ arbitrary = do+ deriveProbabilityMassFunction <- Test.QuickCheck.arbitrary++ Data.CommandOptions.mkCommandOptions <$> (+ either (+ Left . (succ . abs <$> {-into Maybe-monad-})+ ) (+ Right . (+ recip 1000000) . succ . abs+ ) <$> Test.QuickCheck.arbitrary {-binSizeDelta-}+ ) <*> return {-to Gen-monad-} deriveProbabilityMassFunction <*> (+ max (+ if deriveProbabilityMassFunction then 1 else 0+ ) . (+ `mod` 15 {-maximum permissible-}+ ) <$> Test.QuickCheck.arbitrary {-nDecimalDigits-}+ ) <*> Test.QuickCheck.arbitrary {-verbosity-}++-- | Defines a concrete type for testing.+type CommandOptions = Data.CommandOptions.CommandOptions Double+
+ src-test/FishFood/Test/QuickCheck/Data/Verbosity.hs view
@@ -0,0 +1,31 @@+{-# OPTIONS_GHC -fno-warn-orphans #-}+{-+ Copyright (C) 2013 Dr. Alistair Ward++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Implements 'Test.QuickCheck.Arbitrary' for 'Distribution.Verbosity.Verbosity'.+-}++module FishFood.Test.QuickCheck.Data.Verbosity() where++import qualified Distribution.Verbosity+import qualified FishFood.Data.Verbosity as Data.Verbosity+import qualified Test.QuickCheck++instance Test.QuickCheck.Arbitrary Distribution.Verbosity.Verbosity where+ arbitrary = Test.QuickCheck.elements Data.Verbosity.range
+ src-test/FishFood/Test/QuickCheck/Profiler.hs view
@@ -0,0 +1,58 @@+{-+ Copyright (C) 2013-2015 Dr. Alistair Ward++ This program is free software: you can redistribute it and/or modify+ it under the terms of the GNU General Public License as published by+ the Free Software Foundation, either version 3 of the License, or+ (at your option) any later version.++ This program is distributed in the hope that it will be useful,+ but WITHOUT ANY WARRANTY; without even the implied warranty of+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ GNU General Public License for more details.++ You should have received a copy of the GNU General Public License+ along with this program. If not, see <http://www.gnu.org/licenses/>.+-}+{- |+ [@AUTHOR@] Dr. Alistair Ward++ [@DESCRIPTION@] Defines /QuickCheck/-properties for 'Profiler'.+-}++module FishFood.Test.QuickCheck.Profiler(+-- * Constants+ results+) where++import qualified Control.Monad.Writer+import qualified Data.Either+import qualified Data.Set+import qualified FishFood.Data.CommandOptions as Data.CommandOptions+import qualified FishFood.Data.File as Data.File+import qualified FishFood.Profiler as Profiler+import qualified FishFood.Test.QuickCheck.Data.CommandOptions as Test.QuickCheck.Data.CommandOptions+import qualified Test.QuickCheck+import Test.QuickCheck((==>))+import qualified ToolShed.SelfValidate++-- | The constant test-results for this data-type.+results :: IO [Test.QuickCheck.Result]+results = mapM Test.QuickCheck.quickCheckResult [prop_calculateProbabilityMassFunction, prop_calculateFileSizeFrequencyDistribution, prop_attendance] where+ prop_calculateProbabilityMassFunction, prop_calculateFileSizeFrequencyDistribution, prop_attendance :: Test.QuickCheck.Data.CommandOptions.CommandOptions -> [Data.File.FileSize] -> Test.QuickCheck.Property+ prop_calculateProbabilityMassFunction commandOptions fileSizes = not (null fileSizes) && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_calculateProbabilityMassFunction" . (<= recip 1000000) . (+ negate 1) . sum . Data.Either.rights {-probabilities-} . map Profiler.getValue . fst {-distribution-} . Control.Monad.Writer.runWriter . Profiler.calculateFileSizeDistribution commandOptions' $ map abs fileSizes where+ commandOptions' = commandOptions { Data.CommandOptions.getDeriveProbabilityMassFunction = True }++ prop_calculateFileSizeFrequencyDistribution commandOptions fileSizes = not (null fileSizes) && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_calculateFileSizeFrequencyDistribution" . (== length fileSizes) . sum . Data.Either.lefts {-frequency-} . map Profiler.getValue . fst {-distribution-} . Control.Monad.Writer.runWriter . Profiler.calculateFileSizeDistribution commandOptions' $ map abs fileSizes where+ commandOptions' = commandOptions { Data.CommandOptions.getDeriveProbabilityMassFunction = False }++ prop_attendance commandOptions fileSizes = not (null fileSizes') && ToolShed.SelfValidate.isValid commandOptions' ==> Test.QuickCheck.label "prop_attendance" . (+ == Data.Set.fromList fileSizes'+ ) . Data.Set.fromList . map Profiler.getFileSize . filter (+ (/= 0) . either fromIntegral id . Profiler.getValue -- Remove file-sizes which match zero actual files.+ ) . fst {-distribution-} . Control.Monad.Writer.runWriter $ Profiler.calculateFileSizeDistribution commandOptions' fileSizes' where+ fileSizes' = map abs fileSizes++ commandOptions' :: Test.QuickCheck.Data.CommandOptions.CommandOptions+ commandOptions' = Data.CommandOptions.setBinSizeIncrement 1 commandOptions+
src-test/Main.hs view
@@ -24,21 +24,16 @@ module Main(main) where -import Control.Arrow((***)) import qualified Control.Monad-import qualified FishFood.Test.Profiler as Test.Profiler+import qualified FishFood.Test.QuickCheck.Profiler as Test.QuickCheck.Profiler import qualified System.Exit import qualified ToolShed.Test.QuickCheck.Result -- | Entry-point. main :: IO () main = mapM_ (- snd {-exit-status-} . (- putStrLn . (++ ":") *** (- >>= (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful- )- )+ (`Control.Monad.unless` System.Exit.exitFailure) . all ToolShed.Test.QuickCheck.Result.isSuccessful =<< ) [- ("Profiler", Test.Profiler.results)+ Test.QuickCheck.Profiler.results ]