-- This "package" exists because Cabal throws a circular dependency
-- fit if asked to build the top-level package with tests enabled.

name:          bytestring-tests
version:       0.0.0.0
synopsis:      Tests for the bytestring package
description:   Tests for the bytestring package
homepage:      https://github.com/haskell/bytestring
license:       BSD3
license-file:  ../LICENSE
author:        Bryan O'Sullivan <bos@serpentine.com>
maintainer:    Bryan O'Sullivan <bos@serpentine.com>
category:      Data
build-type:    Simple
cabal-version: >=1.8


flag integer-simple
  description: Use the simple integer library instead of GMP
  default: False

-- QC properties, with GHC RULES disabled
test-suite prop-compiled
  type:             exitcode-stdio-1.0
  main-is:          Properties.hs
  other-modules:    Rules
                    QuickCheckUtils
                    Data.ByteString
                    Data.ByteString.Char8
                    Data.ByteString.Internal
                    Data.ByteString.Lazy
                    Data.ByteString.Lazy.Char8
                    Data.ByteString.Lazy.Internal
                    Data.ByteString.Short
                    Data.ByteString.Short.Internal
                    Data.ByteString.Unsafe
  hs-source-dirs:   . ..
  build-depends:    base, ghc-prim, deepseq, random, directory,
                    tasty, tasty-quickcheck,
                    QuickCheck >= 2.10 && < 2.15
  c-sources:        ../cbits/fpstring.c
  include-dirs:     ../include
  cpp-options:      -DHAVE_TEST_FRAMEWORK=1
  ghc-options:      -fwarn-unused-binds
                    -fno-enable-rewrite-rules
                    -threaded -rtsopts
  extensions:       BangPatterns
                    UnliftedFFITypes,
                    MagicHash,
                    ScopedTypeVariables
                    NamedFieldPuns

executable regressions
  main-is:          Regressions.hs
  other-modules:    Data.ByteString
                    Data.ByteString.Internal
                    Data.ByteString.Unsafe
  hs-source-dirs:   . ..
  build-depends:    base, ghc-prim, deepseq, random, directory,
                    tasty, tasty-hunit
  c-sources:        ../cbits/fpstring.c
  include-dirs:     ../include
  cpp-options:      -DHAVE_TEST_FRAMEWORK=1
  ghc-options:      -fwarn-unused-binds
                    -fno-enable-rewrite-rules
                    -threaded -rtsopts
  extensions:       BangPatterns
                    UnliftedFFITypes,
                    MagicHash,
                    ScopedTypeVariables
                    NamedFieldPuns

test-suite test-builder
  type:             exitcode-stdio-1.0
  hs-source-dirs:   . .. builder
  main-is:          TestSuite.hs
  other-modules:    Data.ByteString.Builder.Tests
                    Data.ByteString.Builder.Prim.Tests
                    Data.ByteString.Builder.Prim.TestUtils
                    Data.ByteString
                    Data.ByteString.Builder
                    Data.ByteString.Builder.ASCII
                    Data.ByteString.Builder.Extra
                    Data.ByteString.Builder.Internal
                    Data.ByteString.Builder.Prim
                    Data.ByteString.Builder.Prim.ASCII
                    Data.ByteString.Builder.Prim.Binary
                    Data.ByteString.Builder.Prim.Internal
                    Data.ByteString.Builder.Prim.Internal.Base16
                    Data.ByteString.Builder.Prim.Internal.Floating
                    Data.ByteString.Builder.Prim.Internal.UncheckedShifts
                    Data.ByteString.Internal
                    Data.ByteString.Lazy
                    Data.ByteString.Lazy.Internal
                    Data.ByteString.Short
                    Data.ByteString.Short.Internal
                    Data.ByteString.Unsafe
  build-depends:    base, ghc-prim,
                    deepseq,
                    QuickCheck                 >= 2.10 && < 2.15,
                    byteorder                  == 1.0.*,
                    dlist                      >= 0.5 && < 0.9,
                    directory,
                    mtl                        >= 2.0 && < 2.3,
                    tasty,
                    tasty-hunit,
                    tasty-quickcheck
  cpp-options:      -DHAVE_TEST_FRAMEWORK=1
  ghc-options:      -Wall -fwarn-tabs -threaded -rtsopts
  extensions:       CPP, ForeignFunctionInterface
                    UnliftedFFITypes,
                    MagicHash,
                    ScopedTypeVariables
                    Rank2Types
                    BangPatterns
                    NamedFieldPuns
  c-sources:        ../cbits/fpstring.c
                    ../cbits/itoa.c
  include-dirs:     ../include
  includes:         fpstring.h
  install-includes: fpstring.h

   -- flags for the decimal integer serialization code
  if impl(ghc >= 8.11)
    build-depends: ghc-bignum >= 1.0

  if impl(ghc >= 6.11) && impl(ghc < 8.11)
    if !flag(integer-simple)
      cpp-options: -DINTEGER_GMP
      build-depends: integer-gmp >= 0.2

  if impl(ghc >= 6.9) && impl(ghc < 6.11)
    cpp-options: -DINTEGER_GMP
    build-depends: integer >= 0.1 && < 0.2
