Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #331 #336

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

72 changes: 0 additions & 72 deletions spec/lib/rufo/formatter_source_specs/3.0/pattern_matching.rb.spec

This file was deleted.

20 changes: 20 additions & 0 deletions spec/lib/rufo/formatter_source_specs/method_definition.rb.spec
Original file line number Diff line number Diff line change
Expand Up @@ -361,3 +361,23 @@ end
def foo(...)
p(...)
end

#~# ORIGINAL partial_forward_args
def foo(a, ...)
p(...)
end

#~# EXPECTED
def foo(a, ...)
p(...)
end

#~# ORIGINAL issue_331
def foo a:
a
end

#~# EXPECTED
def foo(a:)
a
end
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,18 @@ def a x;x end;def b y;y end;def c z;z end # comment
def a(x); x end
def b(y); y end
def c(z); z end # comment

#~# ORIGINAL issue_331
#~# parens_in_def: :dynamic
class User
def self.by_uid uid:
joins(:authentications).where(authentications: { uid: }).first
end
end

#~# EXPECTED
class User
def self.by_uid uid:
joins(:authentications).where(authentications: { uid: }).first
end
end
73 changes: 73 additions & 0 deletions spec/lib/rufo/formatter_source_specs/pattern_matching.rb.spec
Original file line number Diff line number Diff line change
Expand Up @@ -938,3 +938,76 @@ case x
in Foo(*)
1
end

#~# ORIGINAL standalone (rightward assignment like syntax)

[0,1,2] => [a,*b]

#~# EXPECTED
[0, 1, 2] => [a, *b]

#~# ORIGINAL find pattern

case [0]
in [*x,
0 => y ,*z]
1
end

#~# EXPECTED
case [0]
in [*x, 0 => y, *z]
1
end

#~# ORIGINAL find pattern unnamed rest args

case [0]
in [*,0,*]
1
end

#~# EXPECTED
case [0]
in [*, 0, *]
1
end

#~# ORIGINAL find pattern multiple sub patterns

case [0,1,3]
in [*,0,1,Integer=>y,*a]
y+(a[0] || 1 )
end

#~# EXPECTED
case [0, 1, 3]
in [*, 0, 1, Integer => y, *a]
y + (a[0] || 1)
end

#~# ORIGINAL find constant pattern with parens

case p
in Point(*, 1,*a)
a
end

#~# EXPECTED
case p
in Point(*, 1, *a)
a
end

#~# ORIGINAL find constant pattern with brackets

case p
in Point[ * , 1 , *a ]
a
end

#~# EXPECTED
case p
in Point[*, 1, *a]
a
end
Loading