Sha256: dfbc3401f2880a9023b4f86eb54a7f39e0d35c309c85b8c28aba05fa4043cd37

Contents?: true

Size: 1.23 KB

Versions: 151

Compression:

Stored size: 1.23 KB

Contents

{-# OPTIONS_GHC -fno-warn-type-defaults #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE OverloadedStrings          #-}

import GHC.Exts          (toList)
import Test.Hspec        (Spec, describe, it, shouldBe)
import Test.Hspec.Runner (configFastFail, defaultConfig, hspecWith)

import Series (slices)

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

specs :: Spec
specs = describe "series" $ do

    -- As of 2016-11-08, there was no reference file
    -- for the test cases in `exercism/x-common`.

    let x `shouldHaveSlices` yss = (map toList . toList) x `shouldBe` yss

    it "slices of one" $ do
      slices 1 ""      `shouldHaveSlices` []
      slices 1 "01234" `shouldHaveSlices` [[0], [1], [2], [3], [4]]

    it "slices of two" $ do
      slices 2 ""      `shouldHaveSlices` []
      slices 2 "01"    `shouldHaveSlices` [[0,1]]
      slices 2 "01234" `shouldHaveSlices` [[0,1], [1,2], [2,3], [3,4]]

    it "slices of three" $ do
      slices 3 "ab"   `shouldHaveSlices` []
      slices 3 "012"  `shouldHaveSlices` [[0,1,2]]
      slices 3 "0123" `shouldHaveSlices` [[0,1,2], [1,2,3]]

    it "slices of zero" $ do
      slices 0 ""    `shouldHaveSlices` [[]]
      slices 0 "012" `shouldHaveSlices` [[]]

Version data entries

151 entries across 151 versions & 1 rubygems

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