我的问题是是否有办法在哈斯克尔的HSpec中测试两个IO actions
?
就像下面的例子:(下面因为类型而错误(
it "parse examples 0" $ liftM2 shouldBe (tests "ex0in.txt") (tests "ex0Out.txt")
tests :: FileType -> IO (Either String String)
我不知道FileType
,我处理它等于FilePath
。
使用做和提升IO
it "parse examples 0" $ do
ex0in <- liftIO (tests "ex0in.txt")
ex0out <- liftIO (tests "ex0Out.txt")
ex0in `shouldBe` ex0out
使用联接和提升IO
it "parse examples 0" $ join $ liftM2 shouldBe (liftIO (tests "ex0in.txt")) (liftIO (tests "ex0Out.txt"))