Sha256: 57f34f26005838b2a1dcee405ae83fb4443b5a0154eb31852168e16d91f8f6a8

Contents?: true

Size: 1.49 KB

Versions: 229

Compression:

Stored size: 1.49 KB

Contents

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

import Test.Hspec        (Spec, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import School (add, empty, grade, sorted)

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

specs :: Spec
specs = do

          let fromList = foldr (uncurry add) empty
          let fromGrade g = fromList . zip (repeat g)

          it "add student" $
            sorted (add 2 "Aimee" empty) `shouldBe` [(2, ["Aimee"])]

          it "add more students in same class" $
            sorted (fromGrade 2 ["James", "Blair", "Paul"])
            `shouldBe` [(2, ["Blair", "James", "Paul"])]

          it "add students to different grades" $
            sorted (fromList [(3, "Chelsea"), (7, "Logan")])
            `shouldBe` [(3, ["Chelsea"]), (7, ["Logan"])]

          it "get students in a grade" $
            grade 5 (fromList [(5, "Franklin"), (5, "Bradley"), (1, "Jeff")])
            `shouldBe` ["Bradley", "Franklin"]

          it "get students in a non-existent grade" $
            grade 1 empty `shouldBe` []

          it "sorted school" $
            sorted (fromList [ (4, "Jennifer"   )
                             , (6, "Kareem"     )
                             , (4, "Christopher")
                             , (3, "Kyle"       ) ] )
            `shouldBe` [ (3, ["Kyle"                   ] )
                       , (4, ["Christopher", "Jennifer"] )
                       , (6, ["Kareem"                 ] ) ]

Version data entries

229 entries across 229 versions & 1 rubygems

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