packages feed

venzone-1.0.0.0: test/VenzoneSpec.hs

module VenzoneSpec where

import Test.Hspec
import Test.QuickCheck

import Venzone
import Terminal.Game
import Lens.Micro.Platform

-- for completion
testRecord :: FilePath -> Expectation
testRecord fp = io `shouldReturn` True
    where
          io :: IO Bool
          io = prepareVenzone    >>= \gv ->
               readRecord fp     >>= \es ->
               let s = testGame gv es in
               pure (s ^. quit)

spec :: Spec
spec = do

  describe "prepareVenzone" $ do
    gv <- runIO prepareVenzone
    -- modifyMaxSize (const 1000) $
    it "prepares a game that does not immediately crash" $ property $
      \e -> let a = testGame gv e in a == a
      -- We should use NFData but it would be another dependency

  -- test playthroughs
  describe "play-throughs" $ do
    it "completes \"First stroll\"" $
      testRecord "test/records/playthrough/first-stroll.vr"
    it "completes \"Bidin\"" $
      testRecord "test/records/playthrough/bidin.vr"
    it "completes \"Orcolat\" (bad ending)" $
      testRecord "test/records/playthrough/orcolat-bad.vr"
    it "completes \"Orcolat\" (good ending)" $
      testRecord "test/records/playthrough/orcolat-good.vr"
    it "completes \"Orcolat\" (better ending)" $
      testRecord "test/records/playthrough/orcolat-better.vr"