我有一个lexer,并希望通过一组已知的好测试用例来测试它。这些文件保存在子目录./test_src/中,每个子目录都有一个扩展
我想做的是找到所有相关测试用例的路径:
getTestFiles :: IO [FilePath]
find always (extension ==? ".txt") "/path/to/test_src/"并创建一个包含HUnit TestList的HUnit TestCases,每个断言都是通过以下代码创建的
testMyLexer :: IO FilePath -> Assertion与…有关的东西
myTest :: [IO FilePath] -> Test
myTest = TestList $ fmap TestCase $ fmap testMyLexer 在我的方法中,我似乎失败的地方是,这似乎首先需要折叠函数,然后映射其结果:
unableToDoThis :: IO [FilePath] -> [IO FilePath]我强烈怀疑我所遵循的方法是不可能的,因为它似乎需要逃离IO Monad,所以我要问的是:
发布于 2013-05-08 18:21:16
通常,如果您在参数中得到包装的IO a值,那么您可能做错了什么。testMyLexer和myTest都可以是纯的,所以
testMyLexer :: IO FilePath -> Assertion
myTest :: [IO FilePath] -> Test做
testMyLexer :: FilePath -> Assertion
myTest :: [FilePath] -> Test那么,这只是一个使用绑定从getTestFiles提取[FilePath]的问题。
do
files <- getTestFiles
runTestTT $ myTest fileshttps://stackoverflow.com/questions/16447072
复制相似问题