We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d25ca2c commit f54296dCopy full SHA for f54296d
1 file changed
core/kernel/Rational_spec.rb
@@ -118,6 +118,15 @@ def obj.to_int; 1; end
118
-> { Rational(nil) }.should raise_error(TypeError, "can't convert nil into Rational")
119
end
120
121
+ it "swallows exception raised in #to_int method" do
122
+ object = Object.new
123
+ def object.to_int() raise NoMethodError; end
124
+
125
+ -> { Rational(object) }.should raise_error(TypeError)
126
+ -> { Rational(object, 1) }.should raise_error(TypeError)
127
+ -> { Rational(1, object) }.should raise_error(TypeError)
128
+ end
129
130
it "raises TypeError if #to_r does not return Rational" do
131
obj = Object.new
132
def obj.to_r; []; end
0 commit comments