<commit_before>module PipelineSpec where

import Data.Functor.Infix ((<$$>))
import Test.Hspec
import Test.QuickCheck
import Test.QuickCheck.Monadic
import Pipeline
import Test
import Eval
import Pretty


runTests :: IO ()
runTests = hspec spec

spec :: Spec
spec = do
  it "Exploratory testing on random program and random pipeline" $ property $
    forAll (PP <$> genProg) $ \(PP original) ->
    forAllShrink genPipeline shrinkPipeline $ \ppln ->
    monadicIO $ do
      transformed      <- run $ pipeline defaultOpts original ppln
      originalValue    <- run $ pure $ evalProgram PureReducer original
      transformedValue <- run $ pure $ evalProgram PureReducer transformed
      run (transformedValue `shouldBe` originalValue)

genPipeline :: Gen [Pipeline]
genPipeline = do
  ((HPT RunHPTPure):) <$> (T <$$> transformations)

shrinkPipeline :: [Pipeline] -> [[Pipeline]]
shrinkPipeline (hpt:rest) = (hpt:) <$> shrinkList (const []) rest

transformations :: Gen [Transformation]
transformations = do
  ts <- shuffle [toEnum 0 .. ]<commit_msg>Add compile HPT as default step in PipelineSpec<commit_after>module PipelineSpec where

import Data.Functor.Infix ((<$$>))
import Test.Hspec
import Test.QuickCheck
import Test.QuickCheck.Monadic
import Pipeline
import Test
import Eval
import Pretty


runTests :: IO ()
runTests = hspec spec

spec :: Spec
spec = do
  it "Exploratory testing on random program and random pipeline" $ property $
    forAll (PP <$> genProg) $ \(PP original) ->
    forAllShrink genPipeline shrinkPipeline $ \ppln ->
    monadicIO $ do
      transformed      <- run $ pipeline defaultOpts original ppln
      originalValue    <- run $ pure $ evalProgram PureReducer original
      transformedValue <- run $ pure $ evalProgram PureReducer transformed
      run (transformedValue `shouldBe` originalValue)

genPipeline :: Gen [Pipeline]
genPipeline = do
  ([HPT CompileHPT, HPT RunHPTPure]++) <$> (T <$$> transformations)

shrinkPipeline :: [Pipeline] -> [[Pipeline]]
shrinkPipeline (chpt:hpt:rest) = ([chpt, hpt]++) <$> shrinkList (const []) rest

transformations :: Gen [Transformation]
transformations = do
  ts <- shuffle [toEnum 0 .. ]
{'fraction_non_alphanumeric': 0.10834485938220378, 'fraction_numerical': 0.0009220839096357768, 'mean_word_length': 4.105882352941176, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '2067838', 'n_tokens_mistral': 674, 'n_tokens_neox': 632, 'n_words': 206}