Indent case statements
This commit is contained in:
parent
b3253c36c5
commit
7694cfeaaa
|
@ -27,6 +27,7 @@ class Pry
|
|||
'if' => 'end',
|
||||
'while' => 'end',
|
||||
'for' => 'end',
|
||||
'case' => 'end',
|
||||
'[' => ']',
|
||||
'{' => '}',
|
||||
'(' => ')'
|
||||
|
@ -44,7 +45,7 @@ class Pry
|
|||
|
||||
# Collection of tokens that should appear dedented even though they
|
||||
# don't affect the surrounding code.
|
||||
MIDWAY_TOKENS = ['else', 'elsif']
|
||||
MIDWAY_TOKENS = ['when', 'else', 'elsif']
|
||||
|
||||
def initialize
|
||||
reset
|
||||
|
|
|
@ -150,6 +150,40 @@ TXT
|
|||
@indent.indent(input).should == output
|
||||
end
|
||||
|
||||
it "should ident case statements" do
|
||||
input = <<TXT.strip
|
||||
case foo
|
||||
when 1
|
||||
2
|
||||
when 2
|
||||
if 3
|
||||
4
|
||||
end
|
||||
when 5
|
||||
#
|
||||
else
|
||||
#
|
||||
end
|
||||
TXT
|
||||
|
||||
output = <<TXT.strip
|
||||
case foo
|
||||
when 1
|
||||
2
|
||||
when 2
|
||||
if 3
|
||||
4
|
||||
end
|
||||
when 5
|
||||
#
|
||||
else
|
||||
#
|
||||
end
|
||||
TXT
|
||||
|
||||
@indent.indent(input).should == output
|
||||
end
|
||||
|
||||
it "should indent correctly with nesting" do
|
||||
@indent.indent("[[\n[]]\n]").should == "[[\n []]\n]"
|
||||
@indent.reset.indent("[[\n[]]\n]").should == "[[\n []]\n]"
|
||||
|
|
Loading…
Reference in New Issue