From de8052cef8a9f749cdb2312a4f5ae5f5a44cf1b8 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 6 Oct 2019 12:50:29 -0400 Subject: Allow eating edible items Add menu support to the prompt system, and an "Eat" command that prompts for an item to eat and eats the item the character specifies, restoring an amount of hitpoints configurable via the item raw type. --- test/Spec.hs | 2 ++ test/Xanthous/UtilSpec.hs | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 test/Xanthous/UtilSpec.hs (limited to 'test') diff --git a/test/Spec.hs b/test/Spec.hs index 7af988a3d7e3..27e26862e255 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -6,6 +6,7 @@ import qualified Xanthous.GameSpec import qualified Xanthous.Generators.UtilSpec import qualified Xanthous.MessageSpec import qualified Xanthous.OrphansSpec +import qualified Xanthous.UtilSpec import qualified Xanthous.Util.GraphicsSpec import qualified Xanthous.Util.InflectionSpec @@ -21,6 +22,7 @@ test = testGroup "Xanthous" , Xanthous.MessageSpec.test , Xanthous.OrphansSpec.test , Xanthous.DataSpec.test + , Xanthous.UtilSpec.test , Xanthous.Util.GraphicsSpec.test , Xanthous.Util.InflectionSpec.test ] diff --git a/test/Xanthous/UtilSpec.hs b/test/Xanthous/UtilSpec.hs new file mode 100644 index 000000000000..1cfca1ffca76 --- /dev/null +++ b/test/Xanthous/UtilSpec.hs @@ -0,0 +1,24 @@ +module Xanthous.UtilSpec (main, test) where + +import Test.Prelude +import Xanthous.Util + +main :: IO () +main = defaultMain test + +test :: TestTree +test = testGroup "Xanthous.Util" + [ testGroup "smallestNotIn" + [ testCase "examples" $ do + smallestNotIn [7 :: Word, 3, 7] @?= 0 + smallestNotIn [7 :: Word, 0, 1, 3, 7] @?= 2 + , testProperty "returns an element not in the list" $ \(xs :: [Word]) -> + smallestNotIn xs `notElem` xs + , testProperty "pred return is in the list" $ \(xs :: [Word]) -> + let res = smallestNotIn xs + in res /= 0 ==> pred res `elem` xs + , testProperty "ignores order" $ \(xs :: [Word]) -> + forAll (shuffle xs) $ \shuffledXs -> + smallestNotIn xs === smallestNotIn shuffledXs + ] + ] -- cgit 1.4.1