Merge pull request #130 from dbogs425/master

Issue 99 - Formatting
pull/122/merge
JP Smith 6 years ago committed by GitHub
commit 0470370710
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      src/Main.hs

@ -1,4 +1,4 @@
{-# LANGUAGE FlexibleContexts, OverloadedStrings, TupleSections #-}
{-# LANGUAGE FlexibleContexts, OverloadedStrings, TupleSections, DoAndIfThenElse #-}
module Main where
@ -59,29 +59,35 @@ main = do
config <- maybe (pure defaultConfig) parseConfig configFile
let f = checkTest (config ^. returnType)
checkGroup = if config ^. outputJson then checkParallelJson else checkParallel
checkGroup = if config ^. outputJson
then
checkParallelJson
else
checkParallel
flip runReaderT config $ do
-- Load solidity contract and get VM
(v,a,ts) <- loadSolidity file (pack <$> contract)
if null ts then throwM NoTests else pure ()
if null ts
then throwM NoTests
else pure ()
if not $ usecov || config ^. printCoverage
-- Run without coverage
then do
let prop t = ePropertySeq (`f` t) a v >>= \x -> return (PropertyName $ show t, x)
_ <- checkGroup . Group (GroupName file) =<< mapM prop ts
return ()
then do
let prop t = ePropertySeq (`f` t) a v >>= \x -> return (PropertyName $ show t, x)
_ <- checkGroup . Group (GroupName file) =<< mapM prop ts
return ()
-- Run with coverage
else do
tests <- liftIO $ mapM (\t -> fmap (t,) (newMVar [])) ts
let prop (cov,t,mvar) =
ePropertySeqCoverage cov mvar (`f` t) a v >>= \x -> return (PropertyName $ show t, x)
else do
tests <- liftIO $ mapM (\t -> fmap (t,) (newMVar [])) ts
let prop (cov,t,mvar) =
ePropertySeqCoverage cov mvar (`f` t) a v >>= \x -> return (PropertyName $ show t, x)
replicateM_ (config ^. epochs) $ do
xs <- liftIO $ forM tests $ \(x,y) -> swapMVar y [] <&> (, x, y) . getCover
checkGroup . Group (GroupName file) =<< mapM prop xs
replicateM_ (config ^. epochs) $ do
xs <- liftIO $ forM tests $ \(x,y) -> swapMVar y [] <&> (, x, y) . getCover
checkGroup . Group (GroupName file) =<< mapM prop xs
ls <- liftIO $ mapM (readMVar . snd) tests
let ci = foldl' (\acc xs -> unions (acc : map snd xs)) mempty ls
liftIO . putStrLn $ "Coverage: " ++ show (size ci) ++ " unique PC's"
ls <- liftIO $ mapM (readMVar . snd) tests
let ci = foldl' (\acc xs -> unions (acc : map snd xs)) mempty ls
liftIO . putStrLn $ "Coverage: " ++ show (size ci) ++ " unique PC's"

Loading…
Cancel
Save