From 8bd1bc47b3e92bfc1c21c698dd7392d8b49a02ef Mon Sep 17 00:00:00 2001 From: KOBAYASHI Shuji Date: Fri, 25 Oct 2019 19:29:19 +0900 Subject: Always add trailing `.0` in `Float#inspect`; ref #4225 Trailing `.0` is removed from `Float#to_s` and `Float#inspect` at 9d08025b. However, I think the more human-readable format is better for `Float#inspect`. For example, in the `Float#to_s` format, the failure message is not well understood when testing values including types by `eql?` (e.g. `Numeric#step` test). ```ruby assert "example" do exp = 1.0 act = 1 assert_operator(exp, :eql?, act) #=> Expected 1 to be eql? 1. end ``` --- test/t/float.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test') diff --git a/test/t/float.rb b/test/t/float.rb index 1cbc90532..e2a8a5088 100644 --- a/test/t/float.rb +++ b/test/t/float.rb @@ -239,6 +239,11 @@ assert('Float#to_s') do end end +assert('Float#inspect') do + assert_equal("-3.25", -3.25.inspect) + assert_equal("50.0", 50.0.inspect) +end + assert('Float#eql?') do assert_operator(5.0, :eql?, 5.0) assert_not_operator(5.0, :eql?, 5) -- cgit v1.2.3