bricks-internal-test (empty) → 0.0.0.4
raw patch · 4 files changed
+117/−0 lines, 4 filesdep +basedep +bricks-internaldep +containers
Dependencies added: base, bricks-internal, containers, hedgehog, template-haskell, text
Files
- bricks-internal-test.cabal +42/−0
- license.txt +13/−0
- src/Bricks/Test/Hedgehog.hs +23/−0
- src/Bricks/Test/QQ.hs +39/−0
+ bricks-internal-test.cabal view
@@ -0,0 +1,42 @@+-- This file has been generated from package.yaml by hpack version 0.20.0.+--+-- see: https://github.com/sol/hpack+--+-- hash: 0102605e86a7c432b4344c0e6488e0062161365637bf0bd6914956408e47c547++name: bricks-internal-test+version: 0.0.0.4+synopsis: ...++description: ...+category: Language+homepage: https://github.com/chris-martin/bricks#readme+bug-reports: https://github.com/chris-martin/bricks/issues+author: Chris Martin <ch.martin@gmail.com>+maintainer: Chris Martin <ch.martin@gmail.com>+license: Apache-2.0+license-file: license.txt+build-type: Simple+cabal-version: >= 1.10++source-repository head+ type: git+ location: https://github.com/chris-martin/bricks++library+ hs-source-dirs:+ src+ ghc-options: -Wall+ build-depends:+ base >=4.9 && <4.11+ , bricks-internal+ , containers >=0.5.7 && <0.6+ , hedgehog >=0.5 && <0.6+ , template-haskell >=2.2 && <2.13+ , text >=1.2.2 && <1.3+ exposed-modules:+ Bricks.Test.Hedgehog+ Bricks.Test.QQ+ other-modules:+ Paths_bricks_internal_test+ default-language: Haskell2010
+ license.txt view
@@ -0,0 +1,13 @@+Copyright 2017 Chris Martin++Licensed under the Apache License, Version 2.0 (the "License");+you may not use this file except in compliance with the License.+You may obtain a copy of the License at++ http://www.apache.org/licenses/LICENSE-2.0++Unless required by applicable law or agreed to in writing, software+distributed under the License is distributed on an "AS IS" BASIS,+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+See the License for the specific language governing permissions and+limitations under the License.
+ src/Bricks/Test/Hedgehog.hs view
@@ -0,0 +1,23 @@+{-# LANGUAGE OverloadedStrings #-}++module Bricks.Test.Hedgehog+ ( runTests+ ) where++-- base+import Control.Monad (unless)+import Data.Foldable (for_)+import qualified System.Exit as Exit+import qualified System.IO as IO++-- hedgehog+import qualified Hedgehog++runTests :: Hedgehog.Group -> IO ()+runTests tests =+ do+ for_ [IO.stdout, IO.stderr] $ \h -> do+ IO.hSetEncoding h IO.utf8+ IO.hSetBuffering h IO.LineBuffering+ success <- Hedgehog.checkParallel tests+ unless success Exit.exitFailure
+ src/Bricks/Test/QQ.hs view
@@ -0,0 +1,39 @@+{-# LANGUAGE OverloadedStrings #-}++module Bricks.Test.QQ+ ( text+ ) where++-- Base+import Control.Arrow ((>>>))+import Data.Function (const)++-- Template Haskell+import Language.Haskell.TH+import Language.Haskell.TH.Quote++-- Text+import qualified Data.Text as Text++text :: QuasiQuoter+text =+ QuasiQuoter+ { quoteExp = pure . LitE . StringL . stripMargin+ , quotePat = err+ , quoteType = err+ , quoteDec = err+ }+ where+ err = const . fail $ "illegal text QuasiQuote (allowed as expression only)"++stripMargin :: String -> String+stripMargin =+ Text.pack+ >>> Text.splitOn "\n"+ >>> fmap (\x ->+ let (a, b) = Text.breakOn "┃" x+ in if Text.all (== ' ') a && not (Text.null b)+ then Text.drop 1 b+ else x)+ >>> Text.intercalate "\n"+ >>> Text.unpack