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

Add more specs for method calls with a space #1063

Merged
merged 1 commit into from
Aug 30, 2023
Merged
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
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