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.139 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.138 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.137 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.136 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.135 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.134 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.133 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.132 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.131 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.130 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.129 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.128 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.127 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.126 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.125 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.124 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.123 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.122 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.121 tracks/elixir/exercises/accumulate/accumulate_test.exs
trackler-2.2.1.120 tracks/elixir/exercises/accumulate/accumulate_test.exs