Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created March 8, 2024 15:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mpickering/ab0ab7a6ded4a3f5996e458114682aae to your computer and use it in GitHub Desktop.
Save mpickering/ab0ab7a6ded4a3f5996e458114682aae to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables, TemplateHaskell #-}
module Main where
-- The testing library
import Test.QuickCheck
import Test.Tasty.QuickCheck
import Test.Tasty
import qualified TEXT1.Data.Text as TEXT1
import qualified TEXT2.Data.Text as TEXT2
equal :: Eq a => (TEXT1.Text -> a) -> (TEXT2.Text -> a) -> String -> Bool
equal f1 f2 x = f1 (TEXT1.pack x) == f2 (TEXT2.pack x)
--------------------------------------------------------------------------
-- example 2
prop_reverse :: String -> Bool
prop_reverse =
equal (TEXT1.unpack . TEXT1.reverse) (TEXT2.unpack . TEXT2.reverse)
prop_length :: String -> Bool
prop_length = equal TEXT1.length TEXT2.length
prop_drop :: Int -> String -> Bool
prop_drop n =
equal (TEXT1.unpack . TEXT1.drop n) (TEXT2.unpack . TEXT2.drop n)
return []
main =
defaultMain (testProperties "Properties" $allProperties)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment