diff options
| author | tv <tv@krebsco.de> | 2026-03-07 23:28:58 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-03-08 04:01:23 +0100 |
| commit | ae9f49e0a6e7d5a0c906d8e4fd153ad553cdecf1 (patch) | |
| tree | 8dbb213f5796da9215742afa9d30682e3dcc5dd0 /test | |
| parent | a6dd9834628614c0b7c815165bc0cf4139131b8c (diff) | |
use mono-traversable
Diffstat (limited to 'test')
| -rw-r--r-- | test/Spec.hs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/test/Spec.hs b/test/Spec.hs index 24a17e2..32bd1e7 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1,9 +1,9 @@ {-# LANGUAGE MultiWayIf #-} {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} -import Blessings.Internal as B -import Blessings.String +import Blessings import Control.Exception +import Data.Sequences qualified as S import System.IO.Unsafe import System.Timeout import Test.Hspec @@ -42,23 +42,23 @@ main = it "take 1 x <> drop 1 x == x" $ property $ \(x :: Blessings String) -> - normalize (B.take 1 x <> B.drop 1 x) == normalize x + normalize (S.take 1 x <> S.drop 1 x) == normalize x it "uncurry (<>) (splitAt i x) == x" $ property $ \(i :: Int, x :: Blessings String) -> unsafeTimeout 100000 $ - normalize (uncurry (<>) (B.splitAt i x)) == normalize x + normalize (uncurry (<>) (S.splitAt i x)) == normalize x it "splitAt produces pairs with elements of proper length" $ property $ \(i :: Int, x :: Blessings String) -> unsafeTimeout 100000 $ let - (l, r) = B.splitAt i x - n = B.length x + (l, r) = S.splitAt i x + n = S.lengthIndex x in - if | i <= 0 -> B.length l == 0 && B.length r == n - | i <= n -> B.length l == i && B.length r == n - i - | otherwise -> B.length l == n && B.length r == 0 + if | i <= 0 -> S.lengthIndex l == 0 && S.lengthIndex r == n + | i <= n -> S.lengthIndex l == i && S.lengthIndex r == n - i + | otherwise -> S.lengthIndex l == n && S.lengthIndex r == 0 let infx = mconcat (repeat (Plain "x" :: Blessings String)) @@ -66,15 +66,15 @@ main = property $ \(n :: NonNegative Int) -> unsafeTimeout 100000 $ let i = getNonNegative n in - B.length (B.take i infx) == i + S.lengthIndex (S.take i infx) == i it "can drop from infinite structure" $ property $ \(n :: NonNegative Int) -> unsafeTimeout 100000 $ let i = getNonNegative n in - B.length (B.take i (B.drop i infx)) == i + S.lengthIndex (S.take i (S.drop i infx)) == i it "can take concat of infinite structures" $ property $ \(x :: Blessings String) -> unsafeTimeout 100000 $ - B.length (B.take 1 $ infx <> x) <= 1 + S.lengthIndex (S.take 1 $ infx <> x) <= 1 |
