Skip to content

Commit

Permalink
Reorganize specs for multiple unnamed arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jun 18, 2015
1 parent c95400b commit ea9f106
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions language/block_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -632,33 +632,17 @@ def m(a) yield a end
@y.m(1, 2) { |_, _| _ }.should == 1
end
end
end

describe "block arguments" do
context "raises an SyntaxError for identical block arguments" do
it "lambda" do
describe "taking identically-named arguments" do
it "raises a SyntaxError for standard arguments" do
lambda { eval "lambda { |x,x| }" }.should raise_error(SyntaxError)
end

it "->" do
lambda { eval "->(x,x) {}" }.should raise_error(SyntaxError)
end

it "Proc" do
lambda { eval "Proc.new { |x,x| }" }.should raise_error(SyntaxError)
end
end

context "not raises an SyntaxError for identical underscores as block arguments" do
it "lambda" do
it "accepts unnamed arguments" do
lambda { eval "lambda { |_,_| }" }.should_not raise_error(SyntaxError)
end

it "->" do
lambda { eval "->(_,_) {}" }.should_not raise_error(SyntaxError)
end

it "Proc" do
lambda { eval "Proc.new { |_,_| }" }.should_not raise_error(SyntaxError)
end
end
Expand Down

2 comments on commit ea9f106

@eregon
Copy link
Member Author

@eregon eregon commented on ea9f106 Jun 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuanitoFatas The spec is easier to read with this organization:

  • It reuses the describe block about arguments
  • All three example should actually fail for the exact same reason: the parser, so it is better to group them as passing some of them does not seem likely or useful.
  • When running with -fs it reads nicely (and that goes as well for tag names, etc):
A block taking identically-named arguments
- raises a SyntaxError for standard arguments
- accepts unnamed arguments

@JuanitoFatas
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted. Will apply to further patches. Thank you! 🙇

Please sign in to comment.