1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
module ReqFailureUnitTests (reqFailureUnitTests) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import Test.Tasty
import Test.Tasty.HUnit
import qualified Content.RuleKind
import Game.LambdaHack.Common.Item
import Game.LambdaHack.Common.ItemAspect
import Game.LambdaHack.Common.Kind (emptyMultiGroupItem)
import Game.LambdaHack.Common.ReqFailure
import Game.LambdaHack.Common.Time
import Game.LambdaHack.Content.ItemKind
import Game.LambdaHack.Definition.Defs
import UnitTestHelpers (stubItem)
reqFailureUnitTests :: TestTree
reqFailureUnitTests = testGroup "reqFailureUnitTests" $
let testItemFull = ItemFull
{ itemBase = stubItem -- Item { jkind = IdentityObvious (toEnum 667) , jfid = Nothing , jflavour = dummyFlavour}
, itemKindId = toEnum 667
, itemKind = emptyMultiGroupItem
, itemDisco = ItemDiscoFull emptyAspectRecord
, itemSuspect = True
}
standardRules = Content.RuleKind.standardRules
in
[ testCase "permittedApply: One Skill and x symbol -> FailureApplyFood" $
permittedApply standardRules timeZero 1 True Nothing
testItemFull quantSingle
@?= Left ApplyFood
, testCase "permittedApply: One Skill and , symbol And CGround -> True" $
permittedApply standardRules timeZero 1 True (Just CGround)
testItemFull {itemKind = emptyMultiGroupItem{isymbol = ','}}
quantSingle
@?= Right True
, testCase "permittedApply: One Skill and \" symbol -> True" $
permittedApply standardRules timeZero 1 True Nothing
testItemFull {itemKind = emptyMultiGroupItem{isymbol = '"'}}
quantSingle
@?= Right True
, testCase "permittedApply: Two Skill and ? symbol -> FailureApplyRead" $
permittedApply standardRules timeZero 2 True Nothing
testItemFull {itemKind = emptyMultiGroupItem{isymbol = '?'}}
quantSingle
@?= Left ApplyRead
, testCase "permittedApply: Two Skill and , symbol -> True" $
permittedApply standardRules timeZero 2 True Nothing
testItemFull {itemKind = emptyMultiGroupItem{isymbol = ','}}
quantSingle
@?= Right True
]
|