Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created March 8, 2024 15:45
Show Gist options
  • Save mpickering/db097bcc7c0e328e99c31480a8e33302 to your computer and use it in GitHub Desktop.
Save mpickering/db097bcc7c0e328e99c31480a8e33302 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)
cabal-version: 3.0
name: testing-text
version: 0.1.0.0
-- synopsis:
-- description:
license: BSD-3-Clause
license-file: LICENSE
author: Matthew Pickering
maintainer: matthewtpickering@gmail.com
-- copyright:
build-type: Simple
extra-doc-files: CHANGELOG.md
-- extra-source-files:
common warnings
ghc-options: -Wall
test-suite testing-text-test
import: warnings
default-language: Haskell2010
-- other-modules:
-- other-extensions:
type: exitcode-stdio-1.0
hs-source-dirs: test
main-is: Main.hs
build-depends: base ^>=4.18.0.0, QuickCheck, tasty-quickcheck, tasty
private-build-depends: TEXT1 with (text == 1.2.*), TEXT2 with (text == 2.*)
benchmark testing-text-benchmarks
import: warnings
default-language: Haskell2010
-- other-modules:
-- other-extensions:
type: exitcode-stdio-1.0
hs-source-dirs: bench/
main-is: Main.hs
build-depends: base ^>=4.18.0.0, tasty-bench, tasty, deepseq
private-build-depends: TEXT1 with (text == 1.2.*), TEXT2 with (text == 2.*)
benchmark testing-text-benchmarks-nfdata
import: warnings
default-language: Haskell2010
-- other-modules:
-- other-extensions:
type: exitcode-stdio-1.0
hs-source-dirs: bench/
main-is: MainNFData.hs
build-depends: base ^>=4.18.0.0, tasty-bench, tasty, deepseq
private-build-depends: TEXT1 with (text == 1.2.*, pretty, containers, template-haskell, bytestring, binary, deepseq), TEXT2 with (text == 2.*, pretty, template-haskell, bytestring, binary, containers, deepseq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment