我可以使用如何使用quickCheckAll
的完整示例。这是我到目前为止所尝试的内容:
在文件A.hs
中:
module A where
import Test.QuickCheck
prop_a = 1 == 0
check = do
return []
$quickCheckAll
在另一个应该驱动测试的文件中:
import A
main :: IO ()
main = do
check
这不起作用,因为check没有类型IO ()
。我应该按照指示in the documentation“执行检查”?
答案 0 :(得分:5)
我认为你误读了the documentation。它指定您应该将 cell = tableView.dequeueReusableCell(withIdentifier: "ContentCell", for: indexPath)
let lblName = (cell.viewWithTag(31)! as! UILabel)
let lblSubmited = (cell.viewWithTag(32)! as! UILabel)
let lblFrom = (cell.viewWithTag(33)! as! UILabel)
let lblTo = (cell.viewWithTag(34)! as! UILabel)
let lblTotalHours = (cell.viewWithTag(35)! as! UILabel)
let lblapprove = (cell.viewWithTag(36)! as! UILabel)
lblName.text = dict.object(forKey: "name") as? String
lblSubmited.text = dict.object(forKey: "submitted") as? String
lblFrom.text = dict.object(forKey: "from") as? String
lblTo.text = dict.object(forKey: "to") as? String
lblTotalHours.text = dict.object(forKey: "tot") as? String
lblapprove.text = "Pending"
let scrollView:UIScrollView!
if(flag.object(at: indexPath.row) as! String == "0"){
scrollView = (cell.viewWithTag(3)! as! UIScrollView)
scrollView.tag = ((100 * indexPath.row)+1)
flag.replaceObject(at: indexPath.row, with: "1")
}
else{
scrollView = (cell.viewWithTag(((100 * indexPath.row)+1))! as! UIScrollView)
}
scrollView.delegate = self
scrollView.showsHorizontalScrollIndicator = false
let viewContent = (cell.viewWithTag(1000)!)
let btApprove = UIButton(frame: CGRect(x: 704.0, y: 10.0, width: 40.0, height: 40.0))
let btReject = UIButton(frame: CGRect(x: 788.0, y: 10.0, width: 40.0, height: 40.0))
let btDetail = UIButton(frame: CGRect(x: 860.0, y: 10.0, width: 40.0, height: 40.0))
btApprove.addTarget(self, action: #selector(self.approvePressedAction), for: .touchUpInside)
btReject.addTarget(self, action: #selector(self.rejectPressedAction), for: .touchUpInside)
btDetail.addTarget(self, action: #selector(self.detailPressedAction), for: .touchUpInside)
viewContent.addSubview(btApprove)
viewContent.addSubview(btReject)
viewContent.addSubview(btDetail)
return cell
写为裸表达式,并且必须使用return []
:
使用Template Haskell测试当前模块中的所有属性。 您需要在模块中使用
TemplateHaskell
pragma 才能使其中任何一个工作。(...)
要使用
{-# LANGUAGE TemplateHaskell #-}
,请按行向模块添加定义 的quickCheckAll
然后执行
return [] runTests = $quickCheckAll
。(...)
注意:GHC 7.8中需要上例中的奇怪
runTests
; 没有它,return []
将无法找到任何属性。好奇的是,quickCheckAll
是一个模板Haskell拼接,使GHC在程序中的那一点插入空的声明列表; GHC在模块的其余部分开始之前检查return []
之前的所有内容,这意味着稍后调用return []
可以看到quickCheckAll
之前定义的所有内容。糟糕!
所以你的第一个文件应该是:
return []
您要测试的所有属性(此处{-# LANGUAGE TemplateHaskell #-}
module A where
import Test.QuickCheck
prop_a = 1 == 0
return []
check = $quickCheckAll
)应在prop_a
之前定义。
和主文件:
return []
您可以使用import A
main :: IO Bool
main = check
,但不会添加任何值。或者如果您希望do
为main
,您可以写:
IO ()
在import A
main :: IO ()
main = do
check
return ()
中执行此操作会发出:
ghci