Bug #19335
Updated by kyanagi (Kouhei Yanagita) about 2 years ago
Thinking of the result of the following, `Integer#remainder` and `Numeric#remainder` should respect `#coerce`. (`BigDecimal#remainder` seems to respect `#coerce`.) ```Ruby c = Object.new def c.coerce(other) [other, 10] end p 1234 / c # => 123 p 1234.div(c) # => 123 p 1234.quo(c) # => (617/5) p 1234.fdiv(c) # => 123.4 p 1234 % c # => 4 p 1234.modulo(c) # => 4 p 1234.divmod(c) # => [123, 4] p 1234.remainder(c) # => in `remainder': comparison of Object with 0 failed (ArgumentError) p 1234.0 / c # => 123.4 123 p 1234.0.div(c) # => 123 p 1234.0.quo(c) # => 123.4 (617/5) p 1234.0.fdiv(c) # => 123.4 p 1234.0 % c # => 4.0 4 p 1234.0.modulo(c) # => 4.0 4 p 1234.0.divmod(c) # => [123, 4.0] 4] p 1234.0.remainder(c) # => in `remainder': comparison of Object with 0 failed (ArgumentError) require 'bigdecimal' p BigDecimal('1234.0').remainder(c) # => 0.4e1 ```