unordered-containers-rematch (empty) → 0.1.0.0
raw patch · 7 files changed
+186/−0 lines, 7 filesdep +HUnitdep +basedep +hashablesetup-changed
Dependencies added: HUnit, base, hashable, hspec, rematch, unordered-containers
Files
- Control/Rematch/HashMap/Lazy.hs +54/−0
- Control/Rematch/HashMap/Strict.hs +54/−0
- Control/Rematch/HashSet.hs +33/−0
- LICENSE +7/−0
- Main.hs +11/−0
- Setup.hs +2/−0
- unordered-containers-rematch.cabal +25/−0
+ Control/Rematch/HashMap/Lazy.hs view
@@ -0,0 +1,54 @@+module Control.Rematch.HashMap.Lazy where+import Data.Hashable+import Data.HashMap.Lazy+import Data.HashMap.Lazy as M+import Control.Rematch++isEmptyMap :: (Show k, Show v, Hashable k) => Matcher (HashMap k v)+isEmptyMap = Matcher {+ match = M.null+ , description = "isEmptyMap"+ , describeMismatch = standardMismatch+ }++hasSize :: (Show k, Show v, Hashable k) => Int -> Matcher (HashMap k v)+hasSize n = Matcher {+ match = (== n) . M.size+ , description = "hasSize " ++ show n+ , describeMismatch = (\m -> "had size " ++ show (M.size m))+ }++hasKey :: (Show k, Show v, Hashable k, Eq k) => k -> Matcher (HashMap k v)+hasKey k = Matcher {+ match = M.member k+ , description = "hasKey " ++ show k+ , describeMismatch = standardMismatch+ }++hasValueAt :: (Show k, Show v, Hashable k, Eq k, Eq v) => k -> v -> Matcher (HashMap k v)+hasValueAt k v = Matcher {+ match = (== Just v) . (M.lookup k)+ , description = "hasValueAt " ++ show k ++ " " ++ show v+ , describeMismatch = (\m -> "was " ++ show (M.lookup k m))+ }++containsMap :: (Show k, Show v, Hashable k, Eq k) => HashMap k v -> Matcher (HashMap k v)+containsMap m = Matcher {+ match = (M.null) . (M.difference m)+ , description = "containsMap " ++ show m+ , describeMismatch = standardMismatch+ }++hasKeys :: (Show k, Show v, Hashable k, Eq k) => [k] -> Matcher (HashMap k v)+hasKeys ks = Matcher {+ match = (== ks) . M.keys+ , description = "hasKeys " ++ show ks+ , describeMismatch = (\m -> "had keys " ++ show (M.keys m))+ }++hasValues :: (Show k, Show v, Hashable k, Eq v) => [v] -> Matcher (HashMap k v)+hasValues vs = Matcher {+ match = (== vs) . M.elems+ , description = "hasValues " ++ show vs+ , describeMismatch = (\m -> "had values " ++ show (M.elems m))+ }
+ Control/Rematch/HashMap/Strict.hs view
@@ -0,0 +1,54 @@+module Control.Rematch.HashMap.Strict where+import Data.Hashable+import Data.HashMap.Strict+import Data.HashMap.Strict as M+import Control.Rematch++isEmptyMap :: (Show k, Show v, Hashable k) => Matcher (HashMap k v)+isEmptyMap = Matcher {+ match = M.null+ , description = "isEmptyMap"+ , describeMismatch = standardMismatch+ }++hasSize :: (Show k, Show v, Hashable k) => Int -> Matcher (HashMap k v)+hasSize n = Matcher {+ match = (== n) . M.size+ , description = "hasSize " ++ show n+ , describeMismatch = (\m -> "had size " ++ show (M.size m))+ }++hasKey :: (Show k, Show v, Hashable k, Eq k) => k -> Matcher (HashMap k v)+hasKey k = Matcher {+ match = M.member k+ , description = "hasKey " ++ show k+ , describeMismatch = standardMismatch+ }++hasValueAt :: (Show k, Show v, Hashable k, Eq k, Eq v) => k -> v -> Matcher (HashMap k v)+hasValueAt k v = Matcher {+ match = (== Just v) . (M.lookup k)+ , description = "hasValueAt " ++ show k ++ " " ++ show v+ , describeMismatch = (\m -> "was " ++ show (M.lookup k m))+ }++containsMap :: (Show k, Show v, Hashable k, Eq k) => HashMap k v -> Matcher (HashMap k v)+containsMap m = Matcher {+ match = (M.null) . (M.difference m)+ , description = "containsMap " ++ show m+ , describeMismatch = standardMismatch+ }++hasKeys :: (Show k, Show v, Hashable k, Eq k) => [k] -> Matcher (HashMap k v)+hasKeys ks = Matcher {+ match = (== ks) . M.keys+ , description = "hasKeys " ++ show ks+ , describeMismatch = (\m -> "had keys " ++ show (M.keys m))+ }++hasValues :: (Show k, Show v, Hashable k, Eq v) => [v] -> Matcher (HashMap k v)+hasValues vs = Matcher {+ match = (== vs) . M.elems+ , description = "hasValues " ++ show vs+ , describeMismatch = (\m -> "had values " ++ show (M.elems m))+ }
+ Control/Rematch/HashSet.hs view
@@ -0,0 +1,33 @@+module Control.Rematch.HashSet where+import Data.HashSet+import Data.Hashable+import qualified Data.HashSet as H+import Control.Rematch(Matcher(..), standardMismatch)++isEmpty :: (Show a) => Matcher (HashSet a)+isEmpty = Matcher {+ match = H.null+ , description = "isEmpty"+ , describeMismatch = standardMismatch+ }++hasSize :: (Show a) => Int -> Matcher (HashSet a)+hasSize n = Matcher {+ match = (== n) . H.size+ , description = "hasSize " ++ show n+ , describeMismatch = (\m -> "had size " ++ show (H.size m))+ }++hasMember :: (Show a, Eq a, Hashable a) => a -> Matcher (HashSet a)+hasMember x = Matcher {+ match = H.member x+ , description = "hasMember " ++ show x+ , describeMismatch = standardMismatch+ }++containsSet :: (Show a, Eq a, Hashable a) => HashSet a -> Matcher (HashSet a)+containsSet h = Matcher {+ match = H.null . H.difference h+ , description = "containsSet " ++ show h+ , describeMismatch = standardMismatch+ }
+ LICENSE view
@@ -0,0 +1,7 @@+Copyright (c) 2013 Tom Crayford++Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:++The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.++THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ Main.hs view
@@ -0,0 +1,11 @@+import qualified Control.Rematch.HashMap.Specs as M+import qualified Control.Rematch.HashSet.Specs as H+import Test.Hspec++main :: IO ()+main = hspec $ specs++specs :: Spec+specs = do+ M.specs+ H.specs
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ unordered-containers-rematch.cabal view
@@ -0,0 +1,25 @@+-- Initial unordered-containers-rematch.cabal generated by cabal init. For+-- further documentation, see http://haskell.org/cabal/users-guide/++name: unordered-containers-rematch+version: 0.1.0.0+synopsis: Rematch support for unordered containers+-- description: +homepage: http://github.com/tcrayford/rematch+license: MIT+license-file: LICENSE+author: Tom Crayford+maintainer: tcrayford@gmail.com+-- copyright: +category: Control+build-type: Simple+cabal-version: >=1.8++library+ exposed-modules: Control.Rematch.HashMap.Lazy, Control.Rematch.HashMap.Strict, Control.Rematch.HashSet+ -- other-modules: + build-depends: base ==4.5.*, unordered-containers >= 0.2, rematch >= 0.2, hashable >= 1.2+test-suite tests+ build-depends: base >= 4.5.0 && < 5, hspec >= 1.4, HUnit >= 1.2, unordered-containers >= 0.2, rematch >= 0.2, hashable >= 1.2+ type: exitcode-stdio-1.0+ main-is: Main.hs