2021-06-14 05:02:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module Xanthous.Game.StateSpec (main, test) where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Test.Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Xanthous.Game.State
|
|
|
|
import Xanthous.Entities.Raws (raws, entityFromRaw)
|
2021-06-19 17:49:20 +02:00
|
|
|
import Control.Monad.Random (evalRandT)
|
|
|
|
import System.Random (getStdGen)
|
2021-06-14 05:02:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
main :: IO ()
|
|
|
|
main = defaultMain test
|
|
|
|
|
|
|
|
test :: TestTree
|
|
|
|
test = testGroup "Xanthous.Game.StateSpec"
|
|
|
|
[ testGroup "entityTypeName"
|
2021-06-19 17:49:20 +02:00
|
|
|
[ testCase "for a creature" $ do
|
2021-06-14 05:02:11 +02:00
|
|
|
let gormlakRaw = raws ^?! ix "gormlak"
|
2021-06-19 17:49:20 +02:00
|
|
|
creature <- runRand $ entityFromRaw gormlakRaw
|
|
|
|
entityTypeName creature @?= "Creature"
|
|
|
|
, testCase "for an item" $ do
|
2021-06-14 05:02:11 +02:00
|
|
|
let stickRaw = raws ^?! ix "stick"
|
2021-06-19 17:49:20 +02:00
|
|
|
item <- runRand $ entityFromRaw stickRaw
|
|
|
|
entityTypeName item @?= "Item"
|
2021-06-14 05:02:11 +02:00
|
|
|
]
|
|
|
|
]
|
2021-06-19 17:49:20 +02:00
|
|
|
where
|
|
|
|
runRand x = evalRandT x =<< getStdGen
|