diff options
author | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-26 11:41:16 -0500 |
---|---|---|
committer | Jeremy Daer <jeremydaer@gmail.com> | 2016-04-26 11:41:16 -0500 |
commit | f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2 (patch) | |
tree | e0e640cfe385b0b1ca5803d801a58c7f0cabc3b1 /activesupport/test | |
parent | 8d4ffc81fb9e1bdd2b4aa310d95d005022834b29 (diff) | |
parent | ffb1df52c1f8a8e1805e310448eb66665804b5fc (diff) | |
download | rails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.tar.gz rails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.tar.bz2 rails-f03c27cad2d3b4a9751cccdc3834f719f1cfbaa2.zip |
Merge pull request #24723 from lvl0nax/array_split_fix
Little perfomance fix for Array#split.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/array/grouping_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activesupport/test/core_ext/array/grouping_test.rb b/activesupport/test/core_ext/array/grouping_test.rb index 2eb0f05141..fb7367b0bf 100644 --- a/activesupport/test/core_ext/array/grouping_test.rb +++ b/activesupport/test/core_ext/array/grouping_test.rb @@ -123,4 +123,12 @@ class SplitTest < ActiveSupport::TestCase assert_equal [[], [2, 3, 4], []], a.split { |i| i == 1 || i == 5 } assert_equal [1, 2, 3, 4, 5], a end + + def test_split_with_repeated_values + a = [1, 2, 3, 5, 5, 3, 4, 6, 2, 1, 3] + assert_equal [[1, 2], [5, 5], [4, 6, 2, 1], []], a.split(3) + assert_equal [[1, 2, 3], [], [3, 4, 6, 2, 1, 3]], a.split(5) + assert_equal [[1, 2], [], [], [], [4, 6, 2, 1], []], a.split { |i| i == 3 || i == 5 } + assert_equal [1, 2, 3, 5, 5, 3, 4, 6, 2, 1, 3], a + end end |