Permalink
Browse files

Cleanup anonymous class and add version guard

  • Loading branch information...
1 parent d0ffdb8 commit 640ebc27e1d31667a7db457d1e3173d83a1f7189 @evanphx evanphx committed Jun 20, 2011
Showing with 39 additions and 50 deletions.
  1. +3 −0 benchmark/bin/benchmark
  2. +5 −0 spec/ruby/language/fixtures/method.rb
  3. +31 −50 spec/ruby/language/method_spec.rb
View
@@ -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
@@ -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
@@ -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 == \

0 comments on commit 640ebc2

Please sign in to comment.