I am currently writing unit tests for my (very simple) blackjack game and my testfile (Tests.hs) does not seem to import my datastructures that I have declared in the file I am doing unit tests for (HelpFunctions.hs). I can acces the functions/methods in this file but not the datastructures. Can someone please help me find the problem?
This is the top of my testfile:
module Tests(performTests) where
import Test.HUnit
import HelpFunctions
cardList = [(Hearts, Ace)]
(...)
and this is the top of the file that i am going to write tests for
module HelpFunctions(Suit, Value, blackjack, cardDeck, shuffleOne,
shuffleCards, getValue, addHand, dealCard, bust,
getHighest
) where
import System.Random
import Control.Monad(when)
{- Suit is one of the four suits or color of a playing card
ie Hearts, Clubs, Diamonds or Spades
INVARIANT: Must be one of the specified.
-}
data Suit = Hearts | Clubs | Diamonds | Spades deriving (Show)
{- Value is the numeric value of a playing card according to the rules of blackjack.
INVARIANT: Must be one of the specified.
-}
data Value = Two | Three | Four | Five | Six | Seven | Eight |
Nine | Ten | Jack | Queen | King | Ace
deriving (Eq, Show)
(...)
And when compiling the testfile I get the error
Tests.hs:6:14: error: Data constructor not in scope: Hearts
|
6 | cardList = [(Hearts, Ace)] | ^^^^^^
Tests.hs:6:22: error: Data constructor not in scope: Ace
|
6 | cardList = [(Hearts, Ace)] | ^^^
I have another file that import HelpFunctions and the datastructures from it and that work without problems.