Emily Miller
Emily Miller

Reputation: 473

Implementing I/O Tasty-Hunit testing for Github autograder

I've been given the task to implement a test for an IO function for GitHub's autograder and Tasty. The function code is as follows:

countLetters :: IO [Int]
countLetters = do 
               putStr "First entry: "
               x <- getLine
               putStr "Second entry: "
               y <- getLine
               putStr "Third entry: "
               z <- getLine
               return [length x, length y, length z]

What I've tried so far is using the following code:

testCase "test_countLetters" $ do
         h <- openFile "/dev/null" ReadMode
         System.IO.hDuplicateTo h stdin
         
         hPutStrLn stdin "Haskell Is Fun"
         result <- countLetters
         assertEqual "Count letters" [7,2,3] result
   
         hClose h

However, I keep getting the error that System.IO does not export hDuplicateTo. I've made sure to import the System.IO at the top of the code. If anyone wants the entire code file with all of the other tests, I am happy to attach it.

Upvotes: 0

Views: 25

Answers (1)

Emily Miller
Emily Miller

Reputation: 473

Closed as @cafce25 provided the answer!

Upvotes: 0

Related Questions