Skip to content

Commit

Permalink
Fix formatter alias-def with no-space before equals (#12073)
Browse files Browse the repository at this point in the history
  • Loading branch information
ftarulla authored Jun 9, 2022
1 parent 7d46284 commit 60e3364
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
13 changes: 12 additions & 1 deletion spec/compiler/formatter/formatter_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,18 @@ describe Crystal::Formatter do
assert_format "alias Foo::Bar = Baz", "alias Foo::Bar = Baz"
assert_format "alias A = (B)"
assert_format "alias A = (B) -> C"

assert_format "alias Foo=Bar", "alias Foo = Bar"
assert_format "alias Foo= Bar", "alias Foo = Bar"
assert_format "alias Foo =Bar", "alias Foo = Bar"
assert_format "alias Foo::Bar=Baz", "alias Foo::Bar = Baz"
assert_format "alias Foo::Bar= Baz", "alias Foo::Bar = Baz"
assert_format "alias Foo::Bar =Baz", "alias Foo::Bar = Baz"
assert_format <<-BEFORE, <<-AFTER
alias Foo=
Bar
BEFORE
alias Foo = Bar
AFTER
assert_format "lib Foo\nend"
assert_format "lib Foo\ntype Foo = Bar\nend", "lib Foo\n type Foo = Bar\nend"
assert_format "lib Foo\nfun foo\nend", "lib Foo\n fun foo\nend"
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/crystal/tools/formatter.cr
Original file line number Diff line number Diff line change
Expand Up @@ -4072,10 +4072,10 @@ module Crystal
accept name
else
write name
next_token
end

next_token_skip_space_or_newline

skip_space
write_token " ", :OP_EQ, " "
skip_space_or_newline

Expand Down

0 comments on commit 60e3364

Please sign in to comment.