mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use Integer#div instead of Integer#/ to avoid side effects from mathn
This commit is contained in:
parent
44f12bbba0
commit
22edb664cf
2 changed files with 9 additions and 1 deletions
|
@ -58,7 +58,7 @@ class Array
|
|||
# size / number gives minor group size;
|
||||
# size % number gives how many objects need extra accommodation;
|
||||
# each group hold either division or division + 1 items.
|
||||
division = size / number
|
||||
division = size.div number
|
||||
modulo = size % number
|
||||
|
||||
# create a new array avoiding dup
|
||||
|
|
|
@ -112,6 +112,14 @@ class ArrayExtToSTests < ActiveSupport::TestCase
|
|||
end
|
||||
|
||||
class ArrayExtGroupingTests < ActiveSupport::TestCase
|
||||
def setup
|
||||
Fixnum.send :private, :/ # test we avoid Integer#/ (redefined by mathn)
|
||||
end
|
||||
|
||||
def teardown
|
||||
Fixnum.send :public, :/
|
||||
end
|
||||
|
||||
def test_in_groups_of_with_perfect_fit
|
||||
groups = []
|
||||
('a'..'i').to_a.in_groups_of(3) do |group|
|
||||
|
|
Loading…
Reference in a new issue