Sha256: 2f5246a90a4fadfca5d5548b567223e969e77a67c93a2476a11f8194ede3d6e3

Contents?: true

Size: 1.71 KB

Versions: 75

Compression:

Stored size: 1.71 KB

Contents

{-# LANGUAGE RecordWildCards #-}

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

import Acronym (abbreviate)

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

specs :: Spec
specs = describe "abbreviate" $ for_ cases test
  where
    test Case {..} = it description $ abbreviate input `shouldBe` expected

data Case = Case { description :: String
                 , input       :: String
                 , expected    :: String
                 }

cases :: [Case]
cases = [ Case { description = "basic"
               , input       = "Portable Network Graphics"
               , expected    = "PNG"
               }
        , Case { description = "lowercase words"
               , input       = "Ruby on Rails"
               , expected    = "ROR"
               }
        -- Although this case was removed in specification 1.1.0,
        -- the Haskell track has chosen to keep it,
        -- since it makes the problem more interesting.
        , Case { description = "camelcase"
               , input       = "HyperText Markup Language"
               , expected    = "HTML"
               }
        , Case { description = "punctuation"
               , input       = "First In, First Out"
               , expected    = "FIFO"
               }
        , Case { description = "all caps word"
               , input       = "GNU Image Manipulation Program"
               , expected    = "GIMP"
               }
        , Case { description = "punctuation without whitespace"
               , input       = "Complementary metal-oxide semiconductor"
               , expected    = "CMOS"
               }
        ]

Version data entries

75 entries across 75 versions & 1 rubygems

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