Sha256: 649fec84570e8e8020774a868a3292e5245394eff68d814e0b2956cf9f35947e

Contents?: true

Size: 1.14 KB

Versions: 166

Compression:

Stored size: 1.14 KB

Contents

module Test.Main where

import Prelude
import Control.Monad.Eff (Eff)
import Test.Unit (suite, test)
import Test.Unit.Main (runTest)
import Test.Unit.Assert as Assert
import Data.List (List, fromFoldable)
import Data.String as String
import Accumulate (accumulate)


main :: Eff _ Unit
main = runTest do
  suite "Accumulate.accumulate" do
    test "empty accumulation" $
      let
        emptyList = (fromFoldable [] :: List Int)
      in
        Assert.equal emptyList $
          accumulate square emptyList

    test "accumulate single square" $
      Assert.equal (fromFoldable [4]) $
        accumulate square (fromFoldable [2])

    test "accumulate squares" $
      Assert.equal (fromFoldable [1, 4, 9]) $
        accumulate square (fromFoldable [1, 2, 3])

    test "accumulate upcases" $
      Assert.equal (fromFoldable ["HELLO", "WORLD"]) $
        accumulate String.toUpper (fromFoldable ["hello", "world"])

    test "accumulate length of strings" $
      Assert.equal (fromFoldable [3, 5, 5, 3, 3]) $
        accumulate String.length (fromFoldable ["the", "quick", "brown", "fox", "etc"])


square :: forall a. (Semiring a) => a -> a
square x = x * x

Version data entries

166 entries across 166 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.52 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.51 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.50 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.49 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.48 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.47 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.46 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.45 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.44 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.43 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.42 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.41 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.40 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.39 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.38 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.37 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.36 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.34 tracks/purescript/exercises/accumulate/test/Main.purs
trackler-2.1.0.33 tracks/purescript/exercises/accumulate/test/Main.purs