<commit_before>{-# Language DeriveDataTypeable #-}
import System.Console.CmdArgs hiding (args)
import FitSpec
import Data.List
import Test.Check
import Test.Types
import Test.Types.Mutate

type Add  a = a -> a -> a
type Prod a = a -> a -> a
type Ty a = ( Add  a
            , Prod a )

propertyMap :: (Listable a, Show a, Eq a, Num a)
            => Int
            -> Add a
            -> Prod a
            -> [Bool]
propertyMap n (+) (*) =
  [ holds n $ \x y   ->       x + y  ==  y + x
  , holds n $ \x y z ->  x + (y + z) == (x + y) + z
  , holds n $ \x     ->        x + 0 == x
  , holds n $ \x     ->        0 + x == x

  , holds n $ \x y   ->       x * y  ==  y * x
  , holds n $ \x y z ->  x * (y * z) == (x * y) * z
  , holds n $ \x     ->        x * 1 == x
  , holds n $ \x     ->        1 * x == x

  , holds n $ \x y z ->  x * (y + z) == (x * y) + (x * z)
  , holds n $ \x y z -> (y + z) * x  == (y * x) + (z * x)
  ]


fns :: Integral a => Ty a
fns = ((+),(*))


sargs :: (Integral a, Show a, Read a)
      => Bool -> Args (Ty a)
sargs useExtra =
  args { limitResults = Nothing
       , showPropertySets = unlines
       , callNames = [ "(+) x y", "(*) x y" ]
       , extraMutants =
           let ems = [ \x y -> x+y+1
                     , \x y -> x*y+x*y
                     , \x y -> x+y+x+y
                     , (+++)
                     , min
                     , max
                     -- another good example would be
                     -- || and && defined over integers
                     ]
           in  tail [ (s,p)
                    | useExtra
                    , s <- (+):(*):ems
                    , p <- (*):(+):ems
                    ]
       }


data CmdArguments = CmdArguments
  { nMutants :: Int
  , nTests :: Int
  , testType :: String
--, classify :: Bool
  , useExtraMutants :: Bool
  , reportType :: String
  } deriving (Data,Typeable,Show,Eq)


arguments = CmdArguments
  { nTests   = 1000    &= help "number of tests to run"
  , nMutants = 1000    &= help "number of mutants to generate"
                       &= name "m"
  , testType = "int"   &= help "type to use"
                       &= name "type"
                       &= name "t"
                       &= explicit
--, classify = False   &= help "classify mutants, report extra column with fully evaluated ones (grey-box)"
  , useExtraMutants = False
                       &= help "pass extra manual mutants to the algorithm (only works for black-box version)"
                       &= name "e"
  , reportType = "default"<commit_msg>black/bench/spring: fix bug (tail empty list)<commit_after>{-# Language DeriveDataTypeable #-}
import System.Console.CmdArgs hiding (args)
import FitSpec
import Data.List
import Test.Check
import Test.Types
import Test.Types.Mutate

type Add  a = a -> a -> a
type Prod a = a -> a -> a
type Ty a = ( Add  a
            , Prod a )

propertyMap :: (Listable a, Show a, Eq a, Num a)
            => Int
            -> Add a
            -> Prod a
            -> [Bool]
propertyMap n (+) (*) =
  [ holds n $ \x y   ->       x + y  ==  y + x
  , holds n $ \x y z ->  x + (y + z) == (x + y) + z
  , holds n $ \x     ->        x + 0 == x
  , holds n $ \x     ->        0 + x == x

  , holds n $ \x y   ->       x * y  ==  y * x
  , holds n $ \x y z ->  x * (y * z) == (x * y) * z
  , holds n $ \x     ->        x * 1 == x
  , holds n $ \x     ->        1 * x == x

  , holds n $ \x y z ->  x * (y + z) == (x * y) + (x * z)
  , holds n $ \x y z -> (y + z) * x  == (y * x) + (z * x)
  ]


fns :: Integral a => Ty a
fns = ((+),(*))


sargs :: (Integral a, Show a, Read a)
      => Bool -> Args (Ty a)
sargs useExtra =
  args { limitResults = Nothing
       , showPropertySets = unlines
       , callNames = [ "(+) x y", "(*) x y" ]
       , extraMutants =
           let ems = [ \x y -> x+y+1
                     , \x y -> x*y+x*y
                     , \x y -> x+y+x+y
                     , (+++)
                     , min
                     , max
                     -- another good example would be
                     -- || and && defined over integers
                     ]
           in drop 1 [ (s,p)
                     | useExtra
                     , s <- (+):(*):ems
                     , p <- (*):(+):ems
                     ]
       }


data CmdArguments = CmdArguments
  { nMutants :: Int
  , nTests :: Int
  , testType :: String
--, classify :: Bool
  , useExtraMutants :: Bool
  , reportType :: String
  } deriving (Data,Typeable,Show,Eq)


arguments = CmdArguments
  { nTests   = 1000    &= help "number of tests to run"
  , nMutants = 1000    &= help "number of mutants to generate"
                       &= name "m"
  , testType = "int"   &= help "type to use"
                       &= name "type"
                       &= name "t"
                       &= explicit
--, classify = False   &= help "classify mutants, report extra column with fully evaluated ones (grey-box)"
  , useExtraMutants = False
                       &= help "pass extra manual mutants to the algorithm (only works for black-box version)"
                       &= name "e"
  , reportType = "default"
{'fraction_non_alphanumeric': 0.14801163918525703, 'fraction_numerical': 0.0052376333656644035, 'mean_word_length': 1.2436901653611836, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5591425', 'n_tokens_mistral': 1734, 'n_tokens_neox': 1631, 'n_words': 563}