File: ast_walker_test.exs

package info (click to toggle)
elixir-earmark-parser 1.4.44-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,148 kB
  • sloc: makefile: 9
file content (38 lines) | stat: -rw-r--r-- 890 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
defmodule Test.Unit.AstWalkerTest do
  use ExUnit.Case

  import EarmarkParser.Ast.Renderer.AstWalker, only: [walk: 2, walk: 3]

  describe "walk a list" do
    test "empty" do
      assert walk([], & &1) == []
    end

    test "one element" do
      str = "do not use a palindrome here"
      assert walk([str], &String.reverse/1) == [String.reverse(str)]
    end
  end

  describe "walk a map" do
    test "empty" do
      assert walk(%{}, & &1) == %{}
    end

    test "one element" do
      str = "do not use a palindrome here"
      assert walk(%{str: str}, &String.reverse/1, true) == %{str: String.reverse(str)}
    end
  end

  describe "walk a tuple" do
    test "empty" do
      assert walk({}, & &1) == {}
    end

    test "one element" do
      str = "do not use a palindrome here"
      assert walk({str}, &String.reverse/1, true) == {String.reverse(str)}
    end
  end
end