Sha256: 8922a65c46563524a9307ddd0af625ee09ceb2da6725a217b523092915b01fb0

Contents?: true

Size: 1.19 KB

Versions: 81

Compression:

Stored size: 1.19 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 "prime-factors" $
          describe "primeFactors" $ for_ cases test
  where

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

    -- Test cases adapted from `exercism/x-common/prime-factors` on 2017-02-01.

    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

81 entries across 81 versions & 1 rubygems

Version Path
trackler-2.1.0.9 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.8 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.7 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.6 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.5 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.4 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.3 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.2 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.1 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.1.0.0 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.55 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.54 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.53 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.52 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.51 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.50 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.49 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.48 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.47 tracks/haskell/exercises/prime-factors/test/Tests.hs
trackler-2.0.8.46 tracks/haskell/exercises/prime-factors/test/Tests.hs