Skip to content

Commit

Permalink
add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
novaugust committed Jun 22, 2023
1 parent 6c2b5c9 commit 26127bc
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/style/module_directives.ex
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ defmodule Styler.Style.ModuleDirectives do
end

defp fix_line_numbers([last], acc), do: Enum.reverse([last | acc])

defp fix_line_numbers([], []), do: []

defp expand_and_sort(directives) do
Expand Down
32 changes: 32 additions & 0 deletions test/style/module_directives_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,36 @@ defmodule Styler.Style.ModuleDirectivesTest do
""")
end
end

describe "with comments..." do
test "moving aliases up through non-directives doesn't move comments up" do
assert_style(
"""
defmodule Foo do
alias B
# hi
# this is foo
def foo do
# i promise it's ok!
:ok
end
alias A
end
""",
"""
defmodule Foo do
@moduledoc false
alias A
alias B
# hi
# this is foo
def foo do
# i promise it's ok!
:ok
end
end
"""
)
end
end
end

0 comments on commit 26127bc

Please sign in to comment.