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 @@ ...@@ -43,10 +43,11 @@
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
}, },
"locked": { "locked": {
"dirtyRev": "e40b8ead4d46261fccf1530507b191d9a1ef831b-dirty", "lastModified": 1708504824,
"dirtyShortRev": "e40b8ea-dirty", "narHash": "sha256-q9kMpixbo9CIq3jj5fJRAq3U+j/o0ooILRD9nYKaHjs=",
"lastModified": 1708355706, "ref": "refs/heads/main",
"narHash": "sha256-a7sHHhQPvDaEjmCAgiAN9OQRJMQNkFVNHzjIu0BYfAg=", "rev": "979d17cf356e3a336dac8820c676ec813668222c",
"revCount": 2,
"type": "git", "type": "git",
"url": "file:///Users/chrg/Develop/repos/hspec-glitter" "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")]} FailureReport {failureReportSeed = 79465390, failureReportMaxSuccess = 100, failureReportMaxSize = 100, failureReportMaxDiscardRatio = 10, failureReportPaths = []}
\ No newline at end of file \ No newline at end of file
// A small test of basic reduction. Should not reduce.
int main() { int main() {
return 0; return 0;
} }
File moved
...@@ -26,38 +26,35 @@ spec = do ...@@ -26,38 +26,35 @@ spec = do
cases <- runIO (listDirectory "test/cases") cases <- runIO (listDirectory "test/cases")
forM_ cases \cname -> do forM_ cases \cname -> do
let cfrom = "test/cases" </> cname </> "main.c" let cfrom = "test/cases" </> cname
let expected = "test/expected" </> cname
onGlitterWith c <- runIO $ parse cfrom
(expected </> "pp.c")
(preproc cfrom)
do
it "should be valid" \(cf, _) ->
validate cf
it "should be parsed equally" \(cf, c) -> do let expected = "test/expected" </> dropExtensions cname
C.parseCFilePre cf >>= \case onGlitterWith (expected </> "main.c") (\fp () -> render fp c) do
Left err -> fail (show err) it "should be valid" . foldMap $ \cf -> do
Right c' -> c' $> () `shouldBe` c $> () validate cf
describe "reduction" do it "should be parsed equally" . foldMap $ \cf -> do
it "should extract itself" \(_, c) -> do C.parseCFilePre cf >>= \case
extract (reduceC c) `shouldBe` c Left err -> fail (show err)
Right c' -> c' $> () `shouldBe` c $> ()
describe "reduction" do
it "should extract itself" do
extract (reduceC c) `shouldBe` c
onGlitterWith onGlitterWith
(expected </> "reduction") (expected </> "reduction")
( \a () -> do ( \a () -> do
c <- parse cfrom
createDirectoryIfMissing True a createDirectoryIfMissing True a
forM_ (take 20 $ iinputs (reduceC c)) \(i, c') -> do forM_ (take 20 $ iinputs (reduceC c)) \(i, c') -> do
let rfile = expected </> "reduction" </> "r" <> debugShow i <.> "c" let rfile = expected </> "reduction" </> "r" <> debugShow i <.> "c"
render rfile c' render rfile c'
pure a
) )
do do
it "should validate all reductions" \a -> do it "should validate all reductions" . mapM_ $ \a -> do
listDirectory a >>= mapM_ \x -> validate a
validate (a </> x)
validate :: FilePath -> IO () validate :: FilePath -> IO ()
validate fp = do validate fp = do
...@@ -77,9 +74,3 @@ parse cfrom = do ...@@ -77,9 +74,3 @@ parse cfrom = do
case cf of case cf of
Left err -> fail (show err) Left err -> fail (show err)
Right cf' -> pure cf' 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