Sha256: 664d226e31eb28f32ba6e417f325d5b2ccdb0346c615b1d647f94d64554d8f16

Contents?: true

Size: 1.6 KB

Versions: 229

Compression:

Stored size: 1.6 KB

Contents

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

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

import ETL (transform)

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

specs :: Spec
specs =

  describe "transform" $ do

    it "a single letter" $
      transform (fromList [(1, "A")])
      `shouldBe` fromList [('a', 1)]

    it "single score with multiple letters" $
      transform (fromList [(1, "AEIOU")])
      `shouldBe` fromList [('a', 1), ('e', 1), ('i', 1), ('o', 1), ('u', 1)]

    it "multiple scores with multiple letters" $
      transform (fromList [(1, "AE"), (2, "DG")])
      `shouldBe` fromList [('a', 1), ('e', 1), ('d', 2), ('g', 2)]

    it "multiple scores with differing numbers of letters" $
      transform (fromList fullInput)
      `shouldBe` fromList fullOutput

  where

    fullInput = [ ( 1, "AEIOULNRST")
                , ( 2, "DG"        )
                , ( 3, "BCMP"      )
                , ( 4, "FHVWY"     )
                , ( 5, "K"         )
                , ( 8, "JX"        )
                , (10, "QZ"        ) ]

    fullOutput = [ ('a',  1) , ('b',  3) , ('c',  3) , ('d',  2)
                 , ('e',  1) , ('f',  4) , ('g',  2) , ('h',  4)
                 , ('i',  1) , ('j',  8) , ('k',  5) , ('l',  1)
                 , ('m',  3) , ('n',  1) , ('o',  1) , ('p',  3)
                 , ('q', 10) , ('r',  1) , ('s',  1) , ('t',  1)
                 , ('u',  1) , ('v',  4) , ('w',  4) , ('x',  8)
                 , ('y',  4) , ('z', 10) ]

Version data entries

229 entries across 229 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.97 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.96 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.95 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.94 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.93 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.92 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.91 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.90 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.89 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.88 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.87 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.86 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.85 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.84 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.83 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.82 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.81 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.80 tracks/haskell/exercises/etl/test/Tests.hs
trackler-2.2.1.79 tracks/haskell/exercises/etl/test/Tests.hs