2021-06-14 05:02:11 +02:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
module Xanthous.Game.StateSpec (main, test) where
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Test.Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
import Xanthous.Game.State
|
2021-11-24 23:10:47 +01:00
|
|
|
import Xanthous.Entities.Raws (raws)
|
|
|
|
import Xanthous.Generators.Level.LevelContents (entityFromRaw)
|
|
|
|
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
|