簡體   English   中英

Hspec處理Haskell中的兩個IO操作

[英]Hspec deal with two IO actions in Haskell

我的問題是在Haskell的HSpec中是否有方法可以測試兩個IO actions

就像下面的示例一樣:(以下由於類型錯誤)

  it "parse examples 0" $ liftM2 shouldBe (tests "ex0in.txt") (tests "ex0Out.txt")

  tests :: FileType -> IO (Either String String)

我不知道FileType ,我認為它等於FilePath

使用do和liftIO

it "parse examples 0" $ do
  ex0in <- liftIO (tests "ex0in.txt")
  ex0out <- liftIO (tests "ex0Out.txt")
  ex0in `shouldBe` ex0out

使用join和liftIO

it "parse examples 0" $ join $ liftM2 shouldBe (liftIO (tests "ex0in.txt")) (liftIO (tests "ex0Out.txt"))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM