Sha256: b914c59fc6caeb2dd47b42ecef98a9c5ca7dcd36bcc43a62dae648c64e88eb8f

Contents?: true

Size: 1.15 KB

Versions: 69

Compression:

Stored size: 1.15 KB

Contents

if !System.get_env("EXERCISM_TEST_EXAMPLES") do
  Code.load_file("accumulate.exs", __DIR__)
end

ExUnit.start()
ExUnit.configure(exclude: :pending, trace: true)

defmodule AccumulateTest do
  use ExUnit.Case

  test "accumulate empty list" do
    assert Accumulate.accumulate([], fn n -> n * n end) == []
  end

  @tag :pending
  test "accumulate square numbers" do
    assert Accumulate.accumulate([1, 2, 3], fn n -> n * n end) == [1, 4, 9]
  end

  @tag :pending
  test "accumulate upcased strings" do
    fun = fn w -> String.upcase(w) end
    assert Accumulate.accumulate(["hello", "world"], fun) == ["HELLO", "WORLD"]
  end

  @tag :pending
  test "accumulate reversed strings" do
    fun = fn w -> String.reverse(w) end
    words = ~w(the quick brown fox etc)
    expected = ["eht", "kciuq", "nworb", "xof", "cte"]
    assert Accumulate.accumulate(words, fun) == expected
  end

  @tag :pending
  test "nested accumulate" do
    chars = ~w(a b c)
    nums = ~w(1 2 3)
    fun = fn c -> Accumulate.accumulate(nums, &(c <> &1)) end
    expected = [["a1", "a2", "a3"], ["b1", "b2", "b3"], ["c1", "c2", "c3"]]
    assert Accumulate.accumulate(chars, fun) == expected
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.179 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.178 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.177 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.176 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.175 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.174 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.173 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.172 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.171 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.170 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.169 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.167 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.166 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.165 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.164 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.163 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.162 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.161 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.160 tracks/elixir/exercises/accumulate/accumulate_test.exs