From 6ab7cdfdc92dc337ec483f3a70ab38560b5aeb63 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 6 Oct 2019 13:13:00 -0400 Subject: Only allow adjacent gormlaks to attack Previously the isUnit function was falsely returning `True` for positions that were one tile off in *either* direction from the character, when it should've been *both*. Oops. --- test/Xanthous/DataSpec.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'test/Xanthous') diff --git a/test/Xanthous/DataSpec.hs b/test/Xanthous/DataSpec.hs index 6b94e6a0582a..26a862baa6a6 100644 --- a/test/Xanthous/DataSpec.hs +++ b/test/Xanthous/DataSpec.hs @@ -26,7 +26,14 @@ test = testGroup "Xanthous.Data" directionOf pos (move dir pos) == dir , testProperty "diffPositions is add inverse" $ \pos₁ pos₂ -> diffPositions pos₁ pos₂ == addPositions pos₁ (invert pos₂) - + , testGroup "isUnit" + [ testProperty "double direction is never unit" $ \dir -> + not . isUnit $ move dir (asPosition dir) + , testCase "examples" $ do + isUnit (Position 1 1) @? "not . isUnit $ Position 1 1" + isUnit (Position 0 (-1)) @? "not . isUnit $ Position 0 (-1)" + (not . isUnit) (Position 1 13) @? "isUnit $ Position 1 13" + ] ] , testGroup "Direction" [ testProperty "opposite is involutive" $ \(dir :: Direction) -> -- cgit 1.4.1