在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):nomeata/inspection-testing开源软件地址(OpenSource Url):https://github.com/nomeata/inspection-testing开源编程语言(OpenSource Language):Haskell 100.0%开源软件介绍(OpenSource Introduction):Inspection Testing for HaskellThis GHC plugin allows you to embed assertions about the intermediate code into your Haskell code, and have them checked by GHC. This is called inspection testing (as it automates what you do when you manually inspect the intermediate code). SynopsisSee the {-# LANGUAGE TemplateHaskell #-}
module Simple where
import Test.Inspection
import Data.Maybe
lhs, rhs :: (a -> b) -> Maybe a -> Bool
lhs f x = isNothing (fmap f x)
rhs f Nothing = True
rhs f (Just _) = False
inspect $ 'lhs === 'rhs If you compile this, you will reassurringly read:
See the If an assertion fails, for example bad1, bad2 :: Int
bad1 = 2 + 2
bad2 = 5
inspect $ 'bad1 === 'bad2 then the compiler will tell you so, and abort the compilation:
What can I check for?Currently, inspection-testing supports
In general, the checks need to be placed in the same module as the checked-definition. Possible further applications includes
Let me know if you need any of these, or have further ideas. Help, I am drowning in Core!inspection-testing prints the Core more or less like GHC would, and the same flags can be used to control the level of detail. In particular, you might want to pass to GHC a selection of the following flags:
It does not seem to do anything (on GHC < 8.4)Add this line to your module:
Can I comment or help?Sure! We can use the GitHub issue tracker for discussions, and obviously contributions are welcome. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论