Skip to content

Commit 33e7df3

Browse files
committed
Test whether nested modules are specified correctly
1 parent f45f794 commit 33e7df3

File tree

5 files changed

+30
-0
lines changed

5 files changed

+30
-0
lines changed
1.3 KB
Binary file not shown.
1.3 KB
Binary file not shown.
1.28 KB
Binary file not shown.

test/examples/nested_modules.ex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmodule NestedModules do
2+
defmodule ModuleA do
3+
def name do
4+
:module_a
5+
end
6+
end
7+
8+
defmodule ModuleB do
9+
def name do
10+
:module_b
11+
end
12+
end
13+
14+
def name do
15+
:module
16+
end
17+
end

test/gradient/ast_specifier_test.exs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,19 @@ defmodule Gradient.AstSpecifierTest do
15781578
assert [_] = AstSpecifier.run_mappers(forms, [])
15791579
end
15801580

1581+
test "nested modules" do
1582+
{tokensA, astA} = load("Elixir.NestedModules.ModuleA.beam", "nested_modules.ex")
1583+
{tokensB, astB} = load("Elixir.NestedModules.ModuleB.beam", "nested_modules.ex")
1584+
{tokens, ast} = load("Elixir.NestedModules.beam", "nested_modules.ex")
1585+
1586+
assert {:function, 3, :name, 0, [{:clause, 3, [], [], [{:atom, 4, :module_a}]}]} =
1587+
List.last(AstSpecifier.run_mappers(astA, tokensA))
1588+
assert {:function, 9, :name, 0, [{:clause, 9, [], [], [{:atom, 10, :module_b}]}]} =
1589+
List.last(AstSpecifier.run_mappers(astB, tokensB))
1590+
assert {:function, 14, :name, 0, [{:clause, 14, [], [], [{:atom, 15, :module}]}]} =
1591+
List.last(AstSpecifier.run_mappers(ast, tokens))
1592+
end
1593+
15811594
# Helpers
15821595

15831596
def filter_attributes(ast, type) do

0 commit comments

Comments
 (0)