ansi-terminal-game-0.4.0.0: test/Terminal/Game/PlaneSpec.hs
module Terminal.Game.PlaneSpec where
import Test.Hspec
import Terminal.Game.Plane
import Terminal.Game.Draw
spec :: Spec
spec = do
let testPlane = blankPlane 2 2 &
(1,1) % box '.' 2 2 &
(1,2) % cell ' '
describe "listPlane" $ do
it "creates a plane from string" $
listPlane (2,2) (map creaCell ". ..") `shouldBe` testPlane
it "ignores extra characters" $
listPlane (2,2) (map creaCell ". ..abc") `shouldBe` testPlane
describe "pastePlane" $ do
it "pastes a simple plane onto another" $
pastePlane (cell 'a') (cell 'b') (1,1) `shouldBe` cell 'a'
describe "trimPlane" $ do
it "trims a plane" $
trimPlane (stringPlane "ab\nc") 1 2 `shouldBe` stringPlane "a\nc"
it "leaves it untouched on bigger dimensions" $
trimPlane (stringPlane "ab\nc") 1 3 `shouldBe` stringPlane "a\nc"
it "other dimesion too" $
trimPlane (stringPlane "ab\nc") 8 9 `shouldBe` stringPlane "ab\nc"
describe "stringPlane" $ do
it "creates plane from spec" $
stringPlane ".\n.." `shouldBe` testPlane
describe "stringPlaneTrans" $ do
it "allows transparency" $
stringPlaneTrans '.' ".\n.." `shouldBe` makeTransparent '.' testPlane
describe "updatePlane" $ do
let ma = listPlane (2,1) (map creaCell "ab")
mb = listPlane (2,1) (map creaCell "xb")
it "updates a Plane" $
updatePlane ma [((1,1), creaCell 'x')] `shouldBe` mb