diff options
| author | KOBAYASHI Shuji <[email protected]> | 2019-10-25 19:29:19 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-10-12 16:21:45 +0900 |
| commit | 8bd1bc47b3e92bfc1c21c698dd7392d8b49a02ef (patch) | |
| tree | 0444d0255d09402e57409aa685480d48bb441558 /test | |
| parent | c45674aff07045517cc4c4333457ea87b9f6a305 (diff) | |
| download | mruby-8bd1bc47b3e92bfc1c21c698dd7392d8b49a02ef.tar.gz mruby-8bd1bc47b3e92bfc1c21c698dd7392d8b49a02ef.zip | |
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
```
Diffstat (limited to 'test')
| -rw-r--r-- | test/t/float.rb | 5 |
1 files changed, 5 insertions, 0 deletions
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) |
