Created
January 6, 2010 12:25
-
-
Save harukizaemon/270239 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From 44d1c70bada4ec43f54e0d8fd2ed56cb9ce4e19b Mon Sep 17 00:00:00 2001 | |
| From: Simon Harris <haruki.zaemon@gmail.com> | |
| Date: Wed, 6 Jan 2010 23:20:27 +1100 | |
| Subject: [PATCH] New failing spec: yield expands arguments that responds to to_ary. | |
| --- | |
| spec/ruby/language/fixtures/yield.rb | 12 ++++++++++++ | |
| spec/ruby/language/yield_spec.rb | 7 +++++++ | |
| 2 files changed, 19 insertions(+), 0 deletions(-) | |
| diff --git a/spec/ruby/language/fixtures/yield.rb b/spec/ruby/language/fixtures/yield.rb | |
| index 8af4913..efc0a5a 100644 | |
| --- a/spec/ruby/language/fixtures/yield.rb | |
| +++ b/spec/ruby/language/fixtures/yield.rb | |
| @@ -1,4 +1,16 @@ | |
| module YieldSpecs | |
| + class ToAry | |
| + attr_reader :to_ary | |
| + | |
| + def initialize(*args) | |
| + @to_ary = args | |
| + end | |
| + end | |
| + | |
| + def self.to_ary | |
| + yield ToAry.new(1, 2) | |
| + end | |
| + | |
| def self.no_block | |
| yield | |
| end | |
| diff --git a/spec/ruby/language/yield_spec.rb b/spec/ruby/language/yield_spec.rb | |
| index 780303b..4027bd2 100644 | |
| --- a/spec/ruby/language/yield_spec.rb | |
| +++ b/spec/ruby/language/yield_spec.rb | |
| @@ -85,6 +85,13 @@ describe "Assignment via yield" do | |
| def f; yield *[*[1,2]]; end; f {|a,b,*c| [a,b,c].should == [1,2,[]] } | |
| end | |
| + it "expands arguments that responds to to_ary" do | |
| + YieldSpecs.to_ary do |a, b| | |
| + a.should == 1 | |
| + b.should == 2 | |
| + end | |
| + end | |
| + | |
| ruby_version_is "" ... "1.9" do | |
| it "assigns objects to splatted block variables that include the splat operator inside the block" do | |
| def f; yield *nil; end; f {|*a| a.should == [nil] } | |
| -- | |
| 1.6.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment