summaryrefslogtreecommitdiffstats
path: root/test/Spec.hs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2025-03-13 21:06:59 +0100
committertv <tv@krebsco.de>2025-07-21 14:57:09 +0200
commit15b6cb2e94243cd8f6c9912a78ee1a5e9738b264 (patch)
tree7b22c54f7fb7c4d939cd371270c1ba86e48a931c /test/Spec.hs
parent50ae155a7fc075694eba6edc2cbc5419ed2731b7 (diff)
add splitAt
Diffstat (limited to 'test/Spec.hs')
-rw-r--r--test/Spec.hs17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/Spec.hs b/test/Spec.hs
index 6cf4d2f..24a17e2 100644
--- a/test/Spec.hs
+++ b/test/Spec.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
import Blessings.Internal as B
@@ -43,6 +44,22 @@ main =
property $ \(x :: Blessings String) ->
normalize (B.take 1 x <> B.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
+
+ 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
+ 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
+
let infx = mconcat (repeat (Plain "x" :: Blessings String))
it "can take from infinite structure" $