@@ -16,7 +16,11 @@ import Control.Monad (void, when)
1616import Control.Monad.IO.Class (MonadIO (.. ))
1717import Data.Function ((&) )
1818import System.Random (split )
19- import Test.Mutagen.Config (DebugMode (.. ))
19+ import Test.Mutagen.Config
20+ ( DebugMode (.. )
21+ , EvaluationOrder (.. )
22+ , LazyPruningMode (.. )
23+ )
2024import Test.Mutagen.Fragment.Store (storeFragments )
2125import Test.Mutagen.Lazy (withLazyIO )
2226import Test.Mutagen.Mutation (Pos )
@@ -376,8 +380,6 @@ runTestCase args parent st = do
376380 message " Running test case..."
377381 -- Run the test case
378382 (result, trace, evaluatedPos) <- liftIO $ execPropRunner st args
379- -- Truncate the trace if necessary
380- let trace' = maybe trace (flip truncateTrace trace) (stMaxTraceLength st)
381383 when (stChatty st) $ do
382384 case evaluatedPos of
383385 Just pos -> do
@@ -387,7 +389,7 @@ runTestCase args parent st = do
387389 return () -- lazy prunning is disabled
388390 -- Print the trace of the mutated test case
389391 message " Test case trace:"
390- pretty (unTrace trace' )
392+ pretty (unTrace trace)
391393 -- Extract property modifiers
392394 let addPropertyModifiers =
393395 setExpect (resultExpect result)
@@ -407,7 +409,7 @@ runTestCase args parent st = do
407409 when (stChatty st) $ do
408410 message " Test result: PASSED"
409411 -- Save the trace in the corresponding trace store
410- (new, prio) <- liftIO (savePassedTraceWithPrio st trace' )
412+ (new, prio) <- liftIO (savePassedTraceWithPrio st trace)
411413 -- Evaluate whether the test case was interesting or not depending on
412414 -- whether it added new trace nodes or not
413415 let interesting = new > 0
@@ -442,7 +444,7 @@ runTestCase args parent st = do
442444 when (stChatty st) $ do
443445 message " Test result: DISCARDED"
444446 -- Save the trace in the corresponding trace log
445- (new, prio) <- liftIO (saveDiscardedTraceWithPrio st trace' )
447+ (new, prio) <- liftIO (saveDiscardedTraceWithPrio st trace)
446448 -- Evaluate whether the test case was interesting or not
447449 --
448450 -- NOTE: in this case, we only consider discarded test cases interesting
@@ -519,19 +521,33 @@ runTestCase args parent st = do
519521
520522-- | Execute a test and capture:
521523-- * The test result (passed, discarded, failed)
522- -- * The trace in the program it traversed
523- -- * The positions of the evaluated expressions of the input
524- -- (if lazy pruning is currently enabled).
524+ -- * The (possibly truncated) execution trace in the program it traversed
525+ -- * The positions of the evaluated subexpressions of the input, in the order
526+ -- that they need to be mutated (only when lazy pruning is enabled).
525527execPropRunner :: MutagenState -> Args -> IO (Result , Trace , Maybe [Pos ])
526528execPropRunner st args
527- | stUseLazyPrunning st = do
528- (evaluated, (test, trace)) <- withLazyIO (withTrace . runProp) args
529- return (test, trace, Just evaluated)
529+ | LazyPruning order <- stLazyPruning st = do
530+ (evaluated, (result, trace)) <- withLazyIO (withTrace . runProp) args
531+ return
532+ ( result
533+ , truncateTraceIfNeeded trace
534+ , Just (withMutationOrder order evaluated)
535+ )
530536 | otherwise = do
531- (test, trace) <- withTrace (runProp args)
532- return (test, trace, Nothing )
537+ (result, trace) <- withTrace (runProp args)
538+ return
539+ ( result
540+ , truncateTraceIfNeeded trace
541+ , Nothing
542+ )
533543 where
534544 runProp = unProp . protectProp . stPropRunner st
545+ withMutationOrder order =
546+ case order of
547+ Forward -> id
548+ Backward -> reverse
549+ truncateTraceIfNeeded trace =
550+ maybe trace (flip truncateTrace trace) (stMaxTraceLength st)
535551
536552-- | Save a discarded trace and return the number of new nodes added and its
537553-- the priority associated to its corresponding test case.
0 commit comments