Sha256: 2d32fc19a1dc2429f25b7dac53f59a753e9d114404965c7bf89cb21fe8bdf4f1

Contents?: true

Size: 1.07 KB

Versions: 229

Compression:

Stored size: 1.07 KB

Contents

{-# OPTIONS_GHC -fno-warn-type-defaults #-}

import Data.Foldable     (for_)
import Test.Hspec        (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import PrimeFactors (primeFactors)

main :: IO ()
main = hspecWith defaultConfig {configFastFail = True} specs

specs :: Spec
specs = describe "primeFactors" $ for_ cases test
  where

    test (description, n, expected) = it description assertion
      where
        assertion   = primeFactors n `shouldBe` expected

    cases = [ ("no factors",                              1,                 [] )
            , ("prime number",                            2,                [2] )
            , ("square of a prime",                       9,             [3, 3] )
            , ("cube of a prime",                         8,          [2, 2, 2] )
            , ("product of primes and non-primes",       12,          [2, 2, 3] )
            , ("product of primes",                  901255,   [5, 17, 23, 461] )
            , ("factors include a large prime", 93819012551, [11, 9539, 894119] ) ]

Version data entries

229 entries across 229 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.179 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.178 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.177 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.176 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.175 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.174 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.173 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.172 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.171 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.170 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.169 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.167 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.166 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.165 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.164 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.163 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.162 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.161 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.2.1.160 tracks/haskell/exercises/prime-factors/test/Tests.hs