<commit_before>{-# LANGUAGE OverloadedStrings #-}

module System.IO.Streams.Tests.Vector (tests) where

------------------------------------------------------------------------------
import           Control.Monad                  hiding (mapM)
import qualified Data.Vector                    as V
import           Prelude                        hiding (mapM, read)
import           Test.Framework
import           Test.Framework.Providers.HUnit
import           Test.HUnit                     hiding (Test)
------------------------------------------------------------------------------
import qualified System.IO.Streams              as S
import           System.IO.Streams.List
import           System.IO.Streams.Vector
------------------------------------------------------------------------------
import           System.IO.Streams.Tests.Common (expectExceptionH)


tests :: [Test]
tests = [ testChunk
        , testWrite
        , testVectorOutputStream
        , testFromTo
        ]


testChunk :: Test
testChunk = testCase "vector/chunkVector" $ do
    let zeroLen :: IO ([V.Vector Int])
        zeroLen = fromList [1..10::Int] >>= chunkVector 0 >>= toList
    expectExceptionH zeroLen

    fromList [1..10 :: Int] >>= chunkVector 3
                            >>= toList
                            >>= assertEqual "chunkVector"
                                  (map V.fromList [ [1,2,3]
                                                  , [4,5,6]
                                                  , [7,8,9]
                                                  , [10]<commit_msg>Formatting wibble.<commit_after>{-# LANGUAGE OverloadedStrings #-}

module System.IO.Streams.Tests.Vector (tests) where

------------------------------------------------------------------------------
import           Control.Monad                  hiding (mapM)
import qualified Data.Vector                    as V
import           Prelude                        hiding (mapM, read)
import           Test.Framework
import           Test.Framework.Providers.HUnit
import           Test.HUnit                     hiding (Test)
------------------------------------------------------------------------------
import qualified System.IO.Streams              as S
import           System.IO.Streams.List
import           System.IO.Streams.Vector
------------------------------------------------------------------------------
import           System.IO.Streams.Tests.Common (expectExceptionH)


------------------------------------------------------------------------------
tests :: [Test]
tests = [ testChunk
        , testWrite
        , testVectorOutputStream
        , testFromTo
        ]


------------------------------------------------------------------------------
testChunk :: Test
testChunk = testCase "vector/chunkVector" $ do
    let zeroLen :: IO ([V.Vector Int])
        zeroLen = fromList [1..10::Int] >>= chunkVector 0 >>= toList
    expectExceptionH zeroLen

    fromList [1..10 :: Int] >>= chunkVector 3
                            >>= toList
                            >>= assertEqual "chunkVector"
                                  (map V.fromList [ [1,2,3]
                                                  , [4,5,6]
                                                  , [7,8,9]
                                                  , [10]
{'fraction_non_alphanumeric': 0.2575712143928036, 'fraction_numerical': 0.011394302848575712, 'mean_word_length': 0.8061721710882512, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7645034', 'n_tokens_mistral': 700, 'n_tokens_neox': 677, 'n_words': 162}