summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix bug in array pack with shared stringsJemma Issroff2022-11-101-0/+6
| | | | | If string literals are long and they become shared, we need to make them independent before we can write to them. [Bug #19116]
* Split tests for `Array#shuffle` and `Array#sample`Nobuyoshi Nakada2022-10-241-1/+21
|
* Fix Array#[] with ArithmeticSequence with negative steps (#5739)Jeremy Evans2022-08-111-0/+90
| | | | | | | | | | | | | | | | | | | | | | * Fix Array#[] with ArithmeticSequence with negative steps Previously, Array#[] when called with an ArithmeticSequence with a negative step did not handle all cases correctly, especially cases involving infinite ranges, inverted ranges, and/or exclusive ends. Fixes [Bug #18247] * Add Array#slice tests for ArithmeticSequence with negative step to test_array Add tests of rb_arithmetic_sequence_beg_len_step C-API function. * Fix ext/-test-/arith_seq/beg_len_step/depend * Rename local variables * Fix a variable name Co-authored-by: Kenta Murata <3959+mrkn@users.noreply.github.com>
* Add missing write barriers to Array#replaceAlan Wu2022-04-281-0/+8
| | | | | | | Previously it made object references without using write barriers, creating GC inconsistencies. See: http://ci.rvm.jp/results/trunk-gc-asserts@phosphorus-docker/3925529
* Use omit instead of skip: test/ruby/**/*.rbHiroshi SHIBATA2022-01-041-1/+1
|
* Refined test [Bug #18140]Nobuyoshi Nakada2021-09-021-1/+4
|
* Test against the target classNobuyoshi Nakada2021-09-021-2/+2
|
* Guard array when appendingAaron Patterson2021-09-021-0/+6
| | | | | | | This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled [ruby-core:105099] [Bug #18140]
* Add negative position tests [Bug #18138]Nobuyoshi Nakada2021-08-291-0/+4
|
* Add out of range tests for Array#slice!Nobuyoshi Nakada2021-08-291-0/+13
|
* Refined portability of test for [Bug #17739]Nobuyoshi Nakada2021-05-221-2/+3
| | | | | The order of arguments to callback of qsort is not defined. That means `a` may not be 3 at all.
* Do not allow array modifications after freeze inside sort!Jeremy Evans2021-05-211-0/+30
| | | | | | | | | If freezing an array inside sort!, previously the array could be modified after the freeze. This checks whether the receiver is frozen after every yield and potential call to #> or #<, preventing modifications if the receiver is frozen inside the block or by the #> or #< call. Fixes [Bug #17739]
* Suppress warnings for unsued variableHiroshi SHIBATA2021-04-231-3/+3
|
* array.c (rb_ary_zip): take only as many as needed from an Enumerator (#4389)Yusuke Endoh2021-04-211-0/+11
| | | [Bug #17814]
* Add Array#intersect?Travis Hunter2021-04-161-0/+13
|
* Ensure the receiver is modifiable before shrinking [Bug #17736]Nobuyoshi Nakada2021-03-201-0/+36
| | | | | * Ensure the receiver is modifiable before shinking [Bug #17736] * Assert the receivers are not modified
* Use category: :deprecated in warnings that are related to deprecationJeremy Evans2020-12-181-15/+15
| | | | | | | | | | | | | | | | | Also document that both :deprecated and :experimental are supported :category option values. The locations where warnings were marked as deprecation warnings was previously reviewed by shyouhei. Comment a couple locations where deprecation warnings should probably be used but are not currently used because deprecation warning enablement has not occurred at the time they are called (RUBY_FREE_MIN, RUBY_HEAP_MIN_SLOTS, -K). Add assert_deprecated_warn to test assertions. Use this to simplify some tests, and fix failing tests after marking some warnings with deprecated category.
* test/ruby: Check warning messages at a finer granularityNobuyoshi Nakada2020-12-171-32/+30
| | | | | Instead of suppressing all warnings wholly in each test scripts by setting `$VERBOSE` to `nil` in `setup` methods.
* Make Array methods return Array instances instead of subclass instancesJeremy Evans2020-11-031-60/+80
| | | | | | | | | | | | | | | | This changes the following methods to return Array instances instead of subclass instances: * Array#drop * Array#drop_while * Array#flatten * Array#slice! * Array#slice/#[] * Array#take * Array#take_while * Array#uniq * Array#* Fixes [Bug #6087]
* Feature #16812: Allow slicing arrays with ArithmeticSequence (#3241)Kenta Murata2020-10-211-1/+37
| | | | | | | | | | | | | | | | | * Support ArithmeticSequence in Array#slice * Extract rb_range_component_beg_len * Use rb_range_values to check Range object * Fix ary_make_partial_step * Fix for negative step cases * range.c: Describe the role of err argument in rb_range_component_beg_len * Raise a RangeError when an arithmetic sequence refers the outside of an array [Feature #16812]
* range.c: Fix an exception message in rb_range_beg_lenKenta Murata2020-10-201-0/+3
| | | | [Bug #17271]
* Ensure that the comparison succeeded [Bug #17205]Nobuyoshi Nakada2020-10-021-0/+21
|
* freeze all Range objects.v3_0_0_preview1Koichi Sasada2020-09-251-1/+1
| | | | | Matz want to try to freeze all Range objects. [Feature #15504]
* Fix Array#flatten for recursive array when given positive depth [Bug #17092]Marc-Andre Lafortune2020-07-301-3/+11
|
* Optimize Array#min (#3324)Kenta Murata2020-07-181-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.min | 39.105M| 39.442M| | | -| 1.01x| |ary10.min | 23.995M| 30.762M| | | -| 1.28x| |ary100.min | 6.249M| 10.783M| | | -| 1.73x| |ary500.min | 1.408M| 2.714M| | | -| 1.93x| |ary1000.min | 828.397k| 1.465M| | | -| 1.77x| |ary2000.min | 332.256k| 570.504k| | | -| 1.72x| |ary3000.min | 338.079k| 573.868k| | | -| 1.70x| |ary5000.min | 168.217k| 286.114k| | | -| 1.70x| |ary10000.min | 85.512k| 143.551k| | | -| 1.68x| |ary20000.min | 43.264k| 71.935k| | | -| 1.66x| |ary50000.min | 17.317k| 29.107k| | | -| 1.68x| |ary100000.min | 9.072k| 14.540k| | | -| 1.60x| |ary1000000.min | 872.930| 1.436k| | | -| 1.64x| compare-ruby is 9f4b7fc82e.
* Optimize Array#max (#3325)Kenta Murata2020-07-181-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The benchmark result is below: | |compare-ruby|built-ruby| |:---------------|-----------:|---------:| |ary2.max | 38.837M| 40.830M| | | -| 1.05x| |ary10.max | 23.035M| 32.626M| | | -| 1.42x| |ary100.max | 5.490M| 11.020M| | | -| 2.01x| |ary500.max | 1.324M| 2.679M| | | -| 2.02x| |ary1000.max | 699.167k| 1.403M| | | -| 2.01x| |ary2000.max | 284.321k| 570.446k| | | -| 2.01x| |ary3000.max | 282.613k| 571.683k| | | -| 2.02x| |ary5000.max | 145.120k| 285.546k| | | -| 1.97x| |ary10000.max | 72.102k| 142.831k| | | -| 1.98x| |ary20000.max | 36.065k| 72.077k| | | -| 2.00x| |ary50000.max | 14.343k| 29.139k| | | -| 2.03x| |ary100000.max | 7.586k| 14.472k| | | -| 1.91x| |ary1000000.max | 726.915| 1.495k| | | -| 2.06x|
* support multiple run for test/ruby/test_array.Koichi Sasada2020-01-281-7/+6
| | | | | test-all supports multiple run with option --repeat-count=2 but test_equal_resize doesn't support it.
* Recheck array length after `to_str` conversionNobuyoshi Nakada2020-01-251-0/+11
| | | | https://hackerone.com/reports/244787
* Recheck elements type after `to_str` conversionNobuyoshi Nakada2020-01-251-0/+10
| | | | https://hackerone.com/reports/244786
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-52/+16
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Add: Array#intersection methodPrajjwal Singh2019-10-071-0/+17
|
* compile.c (compile_list): emit newarraykwsplat only at the last chunkYusuke Endoh2019-09-071-0/+8
| | | | | | | `[{}, {}, {}, ..., {}, *{}]` is wrongly created. A big array literal is created and concatenated for every 256 elements. The newarraykwsplat must be emitted only at the last chunk.
* Make Array#uniq return subclass instance if called on subclass instanceJeremy Evans2019-09-021-0/+25
| | | | | | | | Previously, Array#uniq would return subclass instance if the length of the array were 2 or greater, and would return Array instance if the length of the array were 0 or 1. Fixes [Bug #7768]
* Removing duplicated assertions on test_array.rb - MINUS methodEspartaco Palma2019-08-061-4/+0
| | | | Closes: https://github.com/ruby/ruby/pull/1790
* Implement Array#minmaxJeremy Evans2019-07-021-0/+19
| | | | | | | | | Array#minmax was previous not implemented, so calling #minmax on array was actually calling Enumerable#minmax. This is a simple implementation of #minmax by just calling rb_ary_min and rb_ary_max, which improves performance significantly. Fixes [Bug #15929]
* test/ruby/test_array.rb (test_sort_with_replace): run in a subprocessYusuke Endoh2019-06-261-7/+15
| | | | | | This test invokes GC.start 100 times, which takes approx. six minutes in Solaris. This change runs the test in a separated process, which makes GC.start faster.
* array.c: always check frozenness in Array#unshift. Fixes [Bug #15952]Luke Gruber2019-06-231-0/+11
| | | | Closes: https://github.com/ruby/ruby/pull/2251
* Fix issue with Array#rindex when rb_equal modifies receiver arrayLuke Gruber2019-06-231-0/+10
| | | | | | Fixes [Bug #15951] Closes: https://github.com/ruby/ruby/pull/2250
* Revive accidentally removed assertionkazu2019-04-031-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67424 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Introduce beginless range [Feature#14799]mame2019-04-031-1/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67422 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Mark array as "going to be modified" in `Array#reject!`tenderlove2019-01-081-0/+59
| | | | | | | | | | | Before this patch, if `reject!` is called on a shared array it can mutate the shared array rather than a copy. This patch marks the array as "going to be modified" so that the shared source array isn't mutated. [Bug #15479] [ruby-core:90781] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_array.rb: increase timeout for RubyCIk0kubun2018-12-301-1/+1
| | | | | | https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181230T041101Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_array.rb: increase timeout for RubyCIk0kubun2018-12-281-1/+1
| | | | | | | | | | | | to prevent random failures. test/ruby/test_autoload.rb: ditto test/ruby/test_optimization.rb: ditto https://rubyci.org/logs/rubyci.s3.amazonaws.com/scw-9d6766/ruby-trunk/log/20181228T101706Z.fail.html.gz https://rubyci.org/logs/mswinci.japaneast.cloudapp.azure.com/vc12-x64/ruby-trunk/log/20181228T114549Z.fail.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* range.c: reject ArithmeticSequence in rb_range_valuesmrkn2018-12-211-0/+1
| | | | | | | Reject ArithmeticSequence in rb_range_values so that methods like Array#[] raises TypeError for ArithmeticSequence as an index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix error messagenobu2018-12-041-1/+5
| | | | | | * array.c (ary_take_first_or_last): expected optional argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Revert r63030nobu2018-11-221-1/+3
| | | | | | | * array.c (rb_ary_collect): no longer splat sole array for lambda. [ruby-core:89734] [Bug #15285] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65923 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* appveyor.yml: run memory-exchausting test separatelyk0kubun2018-11-131-1/+0
| | | | | | | | r65690 had no impact https://ci.appveyor.com/project/ruby/ruby/builds/20253561/job/p5u235m8xx85t9o5. Gave up to solve the issue inside the test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_array.rb: try to avoid NoMemoryError on AppVeyork0kubun2018-11-131-0/+1
| | | | | | | | | | We somehow hit NoMemoryError twice on that place. https://ci.appveyor.com/project/ruby/ruby/builds/20224556/job/hlgt963e0cgjbj3c https://ci.appveyor.com/project/ruby/ruby/builds/20250696/job/gm559bu2jbd6youm Let me try firing GC here. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add difference method to Arraynobu2018-10-051-0/+21
| | | | | | | | | | | | | | | | I introduce a `difference` method equivalent to the `-` operator, but which accept more than array as argument. This improved readability, and it is also coherent with the `+` operator, which has a similar `concat` method. The method doesn't modify the original object and return a new object instead. I plan to introduce a `difference!` method as well. Tests and documentation are included. It solves partially https://bugs.ruby-lang.org/issues/14097 From: Ana María Martínez Gómez <ammartinez@suse.de> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64921 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Enumerable#to_h with block and so onnobu2018-09-201-8/+31
| | | | | | [Feature #15143] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e