Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add spec for "argspush" form (as in obj[1, *a] = 2)

  • Loading branch information...
commit 7943e53a10b552041e91e698dc0d4d569589fb5b 1 parent 6fad214
@headius headius authored evanphx committed
Showing with 11 additions and 0 deletions.
  1. +11 −0 spec/ruby/language/method_spec.rb
View
11 spec/ruby/language/method_spec.rb
@@ -191,6 +191,17 @@ def foo(a, b, *c); [c.size, c.last]; end
res.first.should == 2501
res.last.should equal(obj)
end
+
+ it "allows []= form with *args in the [] expanded to individual arguments" do
+ obj = Class.new do
+ attr_reader :result
+ def []=(a, b, c, d); @result = [a,b,c,d]; end
+ end.new
+
+ ary = [2,3]
+ (obj[1, *ary] = 4).should == 4
+ obj.result.should == [1,2,3,4]
+ end
it "allows to pass literal hashes without curly braces as the last parameter" do
def foo(a,b,c); [a,b,c] end
Please sign in to comment.
Something went wrong with that request. Please try again.