From 504912b7cae22b806268db8c403eba78f1e1fb39 Mon Sep 17 00:00:00 2001 From: jcmartin Date: Wed, 27 Nov 2024 11:51:52 -0800 Subject: [PATCH] Added tests for groupBy --- mono-traversable/test/Main.hs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/mono-traversable/test/Main.hs b/mono-traversable/test/Main.hs index dcd4af02..389d4635 100644 --- a/mono-traversable/test/Main.hs +++ b/mono-traversable/test/Main.hs @@ -149,6 +149,26 @@ main = hspec $ do prop "works on lists" $ \(Positive i) j -> ocompareLength (replicate i () :: [()]) j @?= compare i j + describe "groupBy" $ do + let test name dummy = prop name $ \(QCM.NonEmpty xs) -> do + let seq' = fromListAs xs dummy + let listDef f = Prelude.fmap fromList . List.groupBy f . otoList + groupBy (==) seq' @?= listDef (==) seq' + groupBy (/=) seq' @?= listDef (/=) seq' + groupBy (<) seq' @?= listDef (<) seq' + groupBy (>) seq' @?= listDef (>) seq' + test "works on lists" ([] :: [Char]) + test "works on texts" ("" :: Text) + test "works on strict bytestrings" S.empty + test "works on lazy bytestrings" L.empty + test "works on Vector" (V.singleton ('a' :: Char)) + test "works on SVector" (VS.singleton ('a' :: Char)) +#if MIN_VERSION_vector(0,13,2) + test "works on StrictVector" (VSC.singleton ('a' :: Char)) +#endif + test "works on UVector" (U.singleton ('a' :: Char)) + test "works on Seq" (Seq.fromList ['a' :: Char]) + describe "groupAll" $ do it "works on lists" $ groupAll ("abcabcabc" :: String) @?= ["aaa", "bbb", "ccc"] it "works on texts" $ groupAll ("abcabcabc" :: Text) @?= ["aaa", "bbb", "ccc"]