From c91ccefa3eec64a8e11a44306b1776411c6fcb75 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Wed, 30 Aug 2023 16:15:22 +0200 Subject: [PATCH] Add more specs for method calls with a space --- language/method_spec.rb | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/language/method_spec.rb b/language/method_spec.rb index b1d169aba..e9af793d8 100644 --- a/language/method_spec.rb +++ b/language/method_spec.rb @@ -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)")