Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup anonymous class and add version guard

  • Loading branch information...
commit 640ebc27e1d31667a7db457d1e3173d83a1f7189 1 parent d0ffdb8
@evanphx evanphx authored
View
3  benchmark/bin/benchmark
@@ -100,6 +100,9 @@ results = targets.map do |t|
cmd, *rest = t.split(/\s+/)
args.unshift *rest
+ p cmd
+ p args
+
system cmd, *args
if $?.exitstatus != 0
View
5 spec/ruby/language/fixtures/method.rb
@@ -70,4 +70,9 @@ def call_self_foo_or_equals(value)
self.foo ||= 6
end
end
+
+ class AttrSet
+ attr_reader :result
+ def []=(a, b, c, d); @result = [a,b,c,d]; end
+ end
end
View
81 spec/ruby/language/method_spec.rb
@@ -146,60 +146,41 @@ def foobar; 200; 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 []= with multiple *args" do
- cls = Class.new do
- attr_reader :result
- def []=(a, b, c, d); @result = [a,b,c,d]; end
- end
-
- obj = cls.new
-
- ary = [2,3]
- post = [4,5]
- (obj[1, *ary] = *post).should == [4,5]
- obj.result.should == [1,2,3,[4,5]]
- end
-
- it "allows []= with multiple *args and unwraps the last splat" do
- cls = Class.new do
- attr_reader :result
- def []=(a, b, c, d); @result = [a,b,c,d]; end
- end
- obj = cls.new
-
- ary = [2,3]
- post = [4]
- (obj[1, *ary] = *post).should == 4
- obj.result.should == [1,2,3,4]
- end
-
- it "allows []= with a *args and multiple rhs args" do
- cls = Class.new do
- attr_reader :result
- def []=(a, b, c, d); @result = [a,b,c,d]; end
+ ruby_version_is "" ... "1.9" do
+ describe "allows []=" do
+ before :each do
+ @obj = LangMethodSpecs::AttrSet.new
+ end
+
+ it "with *args in the [] expanded to individual arguments" do
+ ary = [2,3]
+ (@obj[1, *ary] = 4).should == 4
+ @obj.result.should == [1,2,3,4]
+ end
+
+ it "with multiple *args" do
+ ary = [2,3]
+ post = [4,5]
+ (@obj[1, *ary] = *post).should == [4,5]
+ @obj.result.should == [1,2,3,[4,5]]
+ end
+
+ it "with multiple *args and unwraps the last splat" do
+ ary = [2,3]
+ post = [4]
+ (@obj[1, *ary] = *post).should == 4
+ @obj.result.should == [1,2,3,4]
+ end
+
+ it "with a *args and multiple rhs args" do
+ ary = [2,3]
+ (@obj[1, *ary] = 4, 5).should == [4,5]
+ @obj.result.should == [1,2,3,[4,5]]
+ end
end
-
- obj = cls.new
-
- ary = [2,3]
- (obj[1, *ary] = 4, 5).should == [4,5]
- obj.result.should == [1,2,3,[4,5]]
end
-
it "allows to pass literal hashes without curly braces as the last parameter" do
specs.fooP3('abc', 456, 'rbx' => 'cool',
'specs' => 'fail sometimes', 'oh' => 'weh').should == \
Please sign in to comment.
Something went wrong with that request. Please try again.