Skip to content

Commit

Permalink
Add more specs for method calls with a space
Browse files Browse the repository at this point in the history
  • Loading branch information
fxn authored and eregon committed Aug 30, 2023
1 parent 7a818ec commit c91ccef
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions language/method_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,42 @@ def n(value, &block)
end
end

context "when a single argument provided" do
it "assigns it" do
context "when a single argument is provided" do
it "assigns a simple expression" do
args = m (1)
args.should == [1]
end

it "assigns an expression consisting of multiple statements" do
args = m ((0; 1))
args.should == [1]
end

it "assigns one single statement, without the need of parentheses" do
args = m (1 == 1 ? true : false)
args.should == [true]
end

it "raises a syntax error if there are multiple statements" do
-> {
eval("m (1; 2)")
}.should raise_error(SyntaxError)
end
end

context "when multiple arguments are provided" do
it "assigns simple expressions" do
args = m (1), (2)
args.should == [1, 2]
end

it "assigns expressions consisting of multiple statements" do
args = m ((0; 1)), ((2; 3))
args.should == [1, 3]
end
end

context "when 2+ arguments provided" do
context "when the argument looks like an argument list" do
it "raises a syntax error" do
-> {
eval("m (1, 2)")
Expand Down

0 comments on commit c91ccef

Please sign in to comment.