Skip to content
Snippets Groups Projects
Commit fcdcd85a authored by chrg's avatar chrg
Browse files

Update the hspec-glitter

parent 8d446a03
No related branches found
No related tags found
No related merge requests found
......@@ -43,10 +43,11 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"dirtyRev": "e40b8ead4d46261fccf1530507b191d9a1ef831b-dirty",
"dirtyShortRev": "e40b8ea-dirty",
"lastModified": 1708355706,
"narHash": "sha256-a7sHHhQPvDaEjmCAgiAN9OQRJMQNkFVNHzjIu0BYfAg=",
"lastModified": 1708504824,
"narHash": "sha256-q9kMpixbo9CIq3jj5fJRAq3U+j/o0ooILRD9nYKaHjs=",
"ref": "refs/heads/main",
"rev": "979d17cf356e3a336dac8820c676ec813668222c",
"revCount": 2,
"type": "git",
"url": "file:///Users/chrg/Develop/repos/hspec-glitter"
},
......
FailureReport {failureReportSeed = 860042728, failureReportMaxSuccess = 100, failureReportMaxSize = 100, failureReportMaxDiscardRatio = 10, failureReportPaths = [(["ReduceC","test/expected/main/reduction"],"should validate all reductions"),(["ReduceC","test/expected/main/reduction"],"should not have changed")]}
\ No newline at end of file
FailureReport {failureReportSeed = 79465390, failureReportMaxSuccess = 100, failureReportMaxSize = 100, failureReportMaxDiscardRatio = 10, failureReportPaths = []}
\ No newline at end of file
// A small test of basic reduction. Should not reduce.
int main() {
return 0;
}
File moved
......@@ -26,38 +26,35 @@ spec = do
cases <- runIO (listDirectory "test/cases")
forM_ cases \cname -> do
let cfrom = "test/cases" </> cname </> "main.c"
let expected = "test/expected" </> cname
onGlitterWith
(expected </> "pp.c")
(preproc cfrom)
do
it "should be valid" \(cf, _) ->
validate cf
let cfrom = "test/cases" </> cname
c <- runIO $ parse cfrom
it "should be parsed equally" \(cf, c) -> do
C.parseCFilePre cf >>= \case
Left err -> fail (show err)
Right c' -> c' $> () `shouldBe` c $> ()
let expected = "test/expected" </> dropExtensions cname
onGlitterWith (expected </> "main.c") (\fp () -> render fp c) do
it "should be valid" . foldMap $ \cf -> do
validate cf
describe "reduction" do
it "should extract itself" \(_, c) -> do
extract (reduceC c) `shouldBe` c
it "should be parsed equally" . foldMap $ \cf -> do
C.parseCFilePre cf >>= \case
Left err -> fail (show err)
Right c' -> c' $> () `shouldBe` c $> ()
describe "reduction" do
it "should extract itself" do
extract (reduceC c) `shouldBe` c
onGlitterWith
(expected </> "reduction")
( \a () -> do
c <- parse cfrom
createDirectoryIfMissing True a
forM_ (take 20 $ iinputs (reduceC c)) \(i, c') -> do
let rfile = expected </> "reduction" </> "r" <> debugShow i <.> "c"
render rfile c'
pure a
)
do
it "should validate all reductions" \a -> do
listDirectory a >>= mapM_ \x ->
validate (a </> x)
it "should validate all reductions" . mapM_ $ \a -> do
validate a
validate :: FilePath -> IO ()
validate fp = do
......@@ -77,9 +74,3 @@ parse cfrom = do
case cf of
Left err -> fail (show err)
Right cf' -> pure cf'
preproc :: FilePath -> FilePath -> () -> IO (FilePath, C.CTranslUnit)
preproc cfrom cto _ = do
cf' <- parse cfrom
render cto cf'
pure (cfrom, cf')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment