mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
parent
cad09f7098
commit
20a85ab611
Notes:
git
2023-01-22 09:53:28 +00:00
Merged-By: mrkn <mrkn@ruby-lang.org>
2 changed files with 5 additions and 1 deletions
|
@ -278,7 +278,7 @@ class Integer
|
|||
#
|
||||
# 3.ceildiv(1.2) # => 3
|
||||
def ceildiv(other)
|
||||
-div(-other)
|
||||
-div(0 - other)
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -725,5 +725,9 @@ class TestInteger < Test::Unit::TestCase
|
|||
|
||||
assert_equal(10, (10**100-11).ceildiv(10**99-1))
|
||||
assert_equal(11, (10**100-9).ceildiv(10**99-1))
|
||||
|
||||
o = Object.new
|
||||
def o.coerce(other); [other, 10]; end
|
||||
assert_equal(124, 1234.ceildiv(o))
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue