File tree Expand file tree Collapse file tree 3 files changed +9
-1
lines changed
spec/ruby/library/bigdecimal Expand file tree Collapse file tree 3 files changed +9
-1
lines changed Original file line number Diff line number Diff line change 3
3
Bug fixes:
4
4
5
5
* Fixed ` BigDecimal#dup ` so it now just returns the receiver, per Ruby 2.5+ semantics (#1680 ).
6
+ * Fixed ` BigDecimal#inspect ` output for non-finite values (e.g, NaN or -Infinity) (#1683 ).
6
7
* Implemented ` rb_eval_string_protect ` .
7
8
* Fixed ` rb_get_kwargs ` to correctly handle optional and rest arguments.
8
9
Original file line number Diff line number Diff line change @@ -245,7 +245,7 @@ def to_s(format = 'E')
245
245
end
246
246
247
247
def inspect
248
- to_s . downcase
248
+ finite? ? to_s . downcase : to_s
249
249
end
250
250
251
251
def _dump ( level = nil )
Original file line number Diff line number Diff line change 14
14
it "looks like this" do
15
15
@bigdec . inspect . should == "0.12345678e4"
16
16
end
17
+
18
+ it "properly cases non-finite values" do
19
+ BigDecimal ( "NaN" ) . inspect . should == "NaN"
20
+ BigDecimal ( "Infinity" ) . inspect . should == "Infinity"
21
+ BigDecimal ( "+Infinity" ) . inspect . should == "Infinity"
22
+ BigDecimal ( "-Infinity" ) . inspect . should == "-Infinity"
23
+ end
17
24
end
You can’t perform that action at this time.
0 commit comments