Tritlo / PropR

Genetic program repair using GHC
MIT License
30 stars 2 forks source link

[Feature] Adds function fits. Fixes #70 #72

Closed Tritlo closed 3 years ago

Tritlo commented 3 years ago

This adds hole fits of the type (_ xs) where xs is some part of the target. E.g

module Wrap where

onlyGoodOnes :: [Int] -> [Int]
onlyGoodOnes = filter even

xs :: [Int]
xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

prop_allEven :: Bool
prop_allEven = all even xs && not (null xs)

---- EXPECTED ----
-- diff --git a/tests/cases/Wrap.hs b/tests/cases/Wrap.hs
-- --- a/tests/cases/Wrap.hs
-- +++ b/tests/cases/Wrap.hs
-- @@ -7,1 +7,1 @@ xs = [1, 2, 3, 4, 5, 6, 7, 8, ...
-- -xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-- +xs = ((filter even) ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
--
-- diff --git a/tests/cases/Wrap.hs b/tests/cases/Wrap.hs
-- --- a/tests/cases/Wrap.hs
-- +++ b/tests/cases/Wrap.hs
-- @@ -7,1 +7,1 @@ xs = [1, 2, 3, 4, 5, 6, 7, 8, ...
-- -xs = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
-- +xs = (onlyGoodOnes ([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]))
---- END EXPECTED ----

Since adding a filter or check at the end is a very common fix, I think this will allow us to fix a lot more program.s