为什么我的测试文件不会导入我的数据结构?哈斯克尔

时间:2018-02-26 01:16:51

标签: haskell data-structures import hunit

我目前正在为我的(非常简单的)二十一点游戏编写单元测试,我的测试文件(Tests.hs)似乎没有导入我在文件中声明的数据结构我正在进行单元测试(HelpFunctions.hs) 。我可以访问此文件中的函数/方法,但不能访问数据结构。 有人可以帮我找到问题吗?

这是我的测试文件的顶部:

module Tests(performTests) where
import Test.HUnit
import HelpFunctions

cardList = [(Hearts, Ace)]
(...)

这是我要为

编写测试的文件的顶部
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)
(...)

编译测试文件时,我收到错误

    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)]   |                      ^^^

我有另一个文件从它导入HelpFunctions和数据结构,并且没有问题。

0 个答案:

没有答案