File: Main.hs

package info (click to toggle)
haskell-text-builder-core 0.1.1.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 96 kB
  • sloc: haskell: 738; makefile: 3
file content (46 lines) | stat: -rw-r--r-- 1,631 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
module Main where

import Data.Proxy
import qualified Data.Text as Text
import qualified Features
import Test.QuickCheck.Classes
import Test.QuickCheck.Instances ()
import Test.Tasty
import Test.Tasty.QuickCheck hiding ((.&.))
import qualified TextBuilderCore as B
import Util.ExtraInstances ()
import Util.TestTrees
import Prelude

main :: IO ()
main = (defaultMain . testGroup "All") tests

tests :: [TestTree]
tests =
  [ testGroup "Legacy" $
      [ testProperty "Packing a list of chars is isomorphic to appending a list of builders" $
          \chars ->
            Text.pack chars
              === B.toText (foldMap B.char chars),
        testProperty "Concatting a list of texts is isomorphic to fold-mapping with builders" $
          \texts ->
            mconcat texts
              === B.toText (foldMap B.text texts),
        testProperty "Concatting a list of texts is isomorphic to concatting a list of builders" $
          \texts ->
            mconcat texts
              === B.toText (mconcat (map B.text texts)),
        testProperty "Concatting a list of trimmed texts is isomorphic to concatting a list of builders" $
          \texts ->
            let trimmedTexts = fmap (Text.drop 3) texts
             in mconcat trimmedTexts
                  === B.toText (mconcat (map B.text trimmedTexts))
      ],
    testGroup "Laws" $
      [ followsLaws $ showLaws (Proxy @B.TextBuilder),
        followsLaws $ eqLaws (Proxy @B.TextBuilder),
        followsLaws $ semigroupLaws (Proxy @B.TextBuilder),
        followsLaws $ monoidLaws (Proxy @B.TextBuilder)
      ],
    testGroup "Features" Features.tests
  ]