diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 15:56:33 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-14 15:56:33 +0000 |
commit | 6479a0163aa798ae379962c6b52f6410b11995cc (patch) | |
tree | 2a63962dc9a2f66cbb4804b4d2bc4680ed00ab3b /spec/rubyspec/core/rational | |
parent | 938465beb05d481b424e9b06a19124c22a881ee0 (diff) |
Update to ruby/spec@a4bc1d8
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/core/rational')
-rw-r--r-- | spec/rubyspec/core/rational/to_r_spec.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/rubyspec/core/rational/to_r_spec.rb b/spec/rubyspec/core/rational/to_r_spec.rb index 22c8b4532c..6e44cf1b23 100644 --- a/spec/rubyspec/core/rational/to_r_spec.rb +++ b/spec/rubyspec/core/rational/to_r_spec.rb @@ -7,4 +7,14 @@ describe "Rational#to_r" do obj = BasicObject.new lambda { Rational(obj) }.should raise_error(TypeError) end + + it "works when a BasicObject has to_r" do + obj = BasicObject.new; def obj.to_r; 1 / 2.to_r end + Rational(obj).should == Rational('1/2') + end + + it "fails when a BasicObject's to_r does not return a Rational" do + obj = BasicObject.new; def obj.to_r; 1 end + lambda { Rational(obj) }.should raise_error(TypeError) + end end |