packages feed

data-forest 0.1.0.11 → 0.1.0.12

raw patch · 3 files changed

+31/−60 lines, 3 filesdep +hspecPVP ok

version bump matches the API change (PVP)

Dependencies added: hspec

API changes (from Hackage documentation)

Files

changelog.md view
@@ -1,3 +1,7 @@+## 0.1.0.12 (2023-06-26)++Change test-suite to hspec+ ## 0.1.0.11 (2023-06-26)  Raise language version to GHC2021
data-forest.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0  name: data-forest-version: 0.1.0.11+version: 0.1.0.12 category: Data Structures synopsis: A simple multi-way tree data structure @@ -21,7 +21,9 @@  common base   default-language: GHC2021-  default-extensions: NoImplicitPrelude+  default-extensions:+      BlockArguments+      NoImplicitPrelude   ghc-options: -Wall   build-depends:     , base ^>= 4.16 || ^>= 4.17 || ^>= 4.18@@ -39,3 +41,4 @@   hs-source-dirs: test   build-depends:     , data-forest+    , hspec ^>= 2.9.7 || ^>= 2.10 || ^>= 2.11
test/Main.hs view
@@ -1,11 +1,9 @@ module Main (main) where -import Control.Applicative (Applicative (pure, (<*>)), (<$>))-import Control.Monad (Functor (fmap), Monad (return, (>>=)))-import Data.Bool (Bool, (&&))+import Control.Applicative ((<$>))+import Control.Monad (Functor (fmap)) import Data.Char (Char, toUpper)-import Data.Eq (Eq ((==)))-import Data.Foldable (Foldable (null, toList))+import Data.Foldable (Foldable (toList)) import Data.Forest   ( Forest (..),     Tree (..),@@ -16,17 +14,15 @@     leaves,     tree,   )-import Data.Function (($), (.))-import Data.List (intercalate, map)+import Data.Function (($), (&), (.))+import Data.List (intercalate) import Data.Semigroup (Semigroup ((<>)))-import Numeric.Natural (Natural)-import System.Exit (die)-import System.IO (IO, putStrLn)-import Text.Show (Show (show))+import System.IO (IO)+import Test.Hspec (hspec, shouldBe, specify)  main :: IO ()-main = dieIfFailures $ do-  test 1 $+main = hspec do+  specify "" do     let example :: Forest Char         example =           forest@@ -37,14 +33,11 @@                     tree 'f' $ leaves "g"                   ]             ]-     in foldForest-          ( intercalate ", "-              . fmap (\(a, b) -> [a] <> " [" <> b <> "]")-          )-          example-          == "a [b [], c []], d [e [], f [g []]]"+    shouldBe+      (example & foldForest (intercalate ", " . fmap (\(a, b) -> [a] <> " [" <> b <> "]")))+      "a [b [], c []], d [e [], f [g []]]" -  test 2 $+  specify "" do     let example :: Tree Char         example =           tree 'a' $@@ -56,14 +49,11 @@                       tree 'g' $ leaves "h"                     ]               ]-     in foldTree-          ( \a bs ->-              [a] <> " [" <> intercalate ", " bs <> "]"-          )-          example-          == "a [b [c [], d []], e [f [], g [h []]]]"+    shouldBe+      (example & foldTree \a bs -> [a] <> " [" <> intercalate ", " bs <> "]")+      "a [b [c [], d []], e [f [], g [h []]]]" -  test 3 $+  specify "" do     let example :: Forest Char         example =           forest@@ -74,19 +64,16 @@                     tree 'f' $ leaves "g"                   ]             ]-        showCharForest f =-          intercalate ", " (showCharTree <$> trees f)+        showCharForest f = intercalate ", " (showCharTree <$> trees f)           where             showCharTree t = case trees (subforest t) of               [] -> [root t]               [t'] -> [root t] <> ": " <> showCharTree t'               _ -> [root t] <> ": (" <> showCharForest (subforest t) <> ")"-     in showCharForest example-          == "a: (b, c), d: (e, f: g)"-          && showCharForest (fmap toUpper example)-            == "A: (B, C), D: (E, F: G)"+    shouldBe (example & showCharForest) "a: (b, c), d: (e, f: g)"+    shouldBe (example & fmap toUpper & showCharForest) "A: (B, C), D: (E, F: G)" -  test 4 $+  specify "" do     let example :: Forest Char         example =           forest@@ -97,27 +84,4 @@                     tree 'f' $ leaves "g"                   ]             ]-     in toList example == "abcdefg"--dieIfFailures :: Failures a -> IO a-dieIfFailures (Failures fs x) =-  if null fs-    then do putStrLn "💯"; return x-    else die $ intercalate " " (map (("🔥" <>) . show) fs)--type TestNumber = Natural--test :: TestNumber -> Bool -> Failures ()-test n t = Failures (if t then [] else [n]) ()--data Failures a = Failures [TestNumber] a--instance Functor Failures where-  fmap f (Failures a x) = Failures a (f x)--instance Applicative Failures where-  pure x = Failures [] x-  Failures a f <*> Failures b x = Failures (a <> b) (f x)--instance Monad Failures where-  Failures a x >>= f = let Failures b y = f x in Failures (a <> b) y+    shouldBe (example & toList) "abcdefg"