aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_enum.rb
Commit message (Collapse)AuthorAgeFilesLines
* * enum.c (ary_inject_op): Use Kahan's compensated summation algorithmmrkn2016-03-231-0/+7
| | | | | | for summing up float values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (ary_inject_op): Implement the specialized code for sum ofakr2016-03-171-1/+9
| | | | | | | | float numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.mame2016-03-171-15/+15
| | | | | | | | | | | | | | | [Feature #12172] * internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can use it. * test/ruby/test_array.rb (test_max, test_min): tests for Array#max and Array#min. * test/ruby/test_enum.rb (test_max, test_min): revised a bit to test Enumerable#max and #min explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Implement the specialized code for sum ofakr2016-03-171-0/+36
| | | | | | | | | | | | integers including Bignums. * internal.h (rb_fix_plus): Declared to be usable from enum_inject. * numeric.c (rb_fix_plus): Defined. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_inject): Consider redefinition of Fixnum#+.akr2016-03-151-0/+12
| | | | | | | | [ruby-dev:49510] [Bug#12178] Reported by usa. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54122 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby: suppress parser warningsnobu2016-02-191-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (nmin_filter): Fix limit value.akr2015-10-041-0/+5
| | | | | | | | | patch by Helder Pereira. [Bug #11471] [ruby-core:70477] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52026 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: added doc for Enumerable#ziphsbt2015-08-111-1/+4
| | | | | | | | [fix GH-985] Patch by @yui-knk * test/ruby/test_enum.rb: added tests for Enumerable#zip [fix GH-985] Patch @yui-knk git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* all?, any?, one?, none? of empty Enumerablenobu2015-07-041-0/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Add test case for empty array and first method with args.hsbt2015-07-041-0/+1
| | | | | | Patch by @yui-knk [fix GH-955] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Add test for `Enumerable#sort` with block. Patch by @yui-knkhsbt2015-07-041-0/+1
| | | | | | [fix GH-954] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * Add test for Enumerable#none? [fix GH-950] Patch by @yui-knkhsbt2015-07-011-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c (enum_minmax): simplify return value creationnormal2015-06-251-0/+1
| | | | | | | | | | | | | | No need to call three functions on success when one will do. This results in less LoC and smaller object code, too: text data bss dec hex filename 33860 0 296 34156 856c gcc/enum.o-before 33852 0 296 34148 8564 gcc/enum.o * enum.c (enum_minmax): simplify return value creation * test/ruby/test_enum.rb: test behavior on empty git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51036 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_chunk_while): New method Enumerable#chunk_while.akr2015-06-141-0/+5
| | | | | | | | [ruby-core:67738] [Feature #10769] proposed by Tsuyoshi Sawada. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm.c: break from orphan blocknobu2015-06-121-2/+19
| | | | | | | | * vm.c (rb_vm_search_cf_from_ep): break from orphan block is possible condition, but not [BUG]. [ruby-core:69548] [Bug #11254] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_grep_v, grep_i, grep_iter_i, Init_enum):sorah2015-05-141-0/+12
| | | | | | Implement Enumerable#grep_v. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_to_a): fix incompatibility introduced in r50457.glass2015-05-121-0/+30
| | | | | | | | [Bug #11130] * test/ruby/test_enum.rb: test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50477 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_enum.rb: use assert_warningnobu2015-04-201-15/+1
| | | | | | | * test/ruby/test_enum.rb (test_slice_before): use assert_warning defined in test/lib/envutils.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: Enumerable#chunk and Enumerable#slice_before no longer takesakr2015-04-061-32/+0
| | | | | | | | the initial_state argument. [Feature #10958] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: limit sizenobu2015-02-281-0/+16
| | | | | | | | * enum.c (enum_each_slice, enum_each_cons): limit elements size by the enumerator size. suggested by Hans Mackowiak <hanmac AT gmx.de> at [ruby-core:68335] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test/ruby: suppress warningsnobu2014-11-291-1/+1
| | | | | | | | | | | | | | | * test/ruby/test_array.rb: (need_continuation): suppress warnings to require continuation. * test/ruby/test_continuation.rb: ditto. * test/ruby/test_enum.rb: ditto. * test/ruby/test_fiber.rb: ditto. * test/ruby/test_hash.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: nil if no iterationnobu2014-10-151-0/+1
| | | | | | | * enum.c (enum_inject): return nil if no iteration, instead of Qundef. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (nmin_run): max(n) and max_by(n) returns an array inakr2014-10-131-3/+3
| | | | | | | | | descending order. [ruby-core:65452] Suggested by David Grayson. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_slice_when): New method: Enumerable#slice_when.akr2014-09-201-0/+55
| | | | | | | | | | | | | | (slicewhen_i): New function. (slicewhen_ii): New function. * enumerator.c (InitVM_Enumerator): New method: Enumerator::Lazy#slice_when. [ruby-core:62499] [Feature #9826] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: Enumerable#slice_after implemented.akr2014-05-181-0/+43
| | | | | | | | | | * enumerator.c: Enumerator::Lazy#slice_after implemented. Requested by Tsuyoshi Sawada. [ruby-core:58123] [Feature #9071] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45981 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_enum.rb (test_flat_map): Added test for flat_map.hsbt2014-04-261-0/+22
| | | | | | Contribute from @igaiga. [fix GH-598] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: fix condition to recycle block argumentnobu2014-04-161-0/+10
| | | | | | | | * enum.c (dont_recycle_block_arg): fix condition to recycle block argument. lambda with rest can get internal array directly. [ruby-core:62060] [Bug #9749] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* test_enum.rb: add testsnobu2014-04-161-0/+12
| | | | | | | * test/ruby/test_enum.rb (test_each_slice, test_each_cons): add missing tests for Enumerable#each_slice and Enumerable#each_cons. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* vm_insnhelper.c: relax arity checknobu2014-03-131-0/+111
| | | | | | | | | | | * vm.c (invoke_block_from_c): add splattable argument. * vm.c (vm_invoke_proc): disallow to splat when directly invoked. * vm_insnhelper.c (vm_callee_setup_arg_complex, vm_callee_setup_arg): relax arity check of yielded lambda. [ruby-core:61340] [Bug #9605] * test/ruby/test_yield.rb (TestRubyYieldGen#emu_bind_params): no longer raise ArgumentError when splatting to lambda. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45327 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* revert [Bug #9605]nobu2014-03-121-111/+0
| | | | | | | * enum.c: revert r45284, r45286, r45292. it conflicts with existing behaviors. [Bug #9605] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* enum.c: yield multiple valuesnobu2014-03-071-0/+111
| | | | | | | | | * enum.c (find_i): yield multiple values instead of a packed array, so that lambda block can work. with tests by Alex Rothenberg. [ruby-core:61340] [Bug #9605] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby: get rid of warnings.usa2014-03-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: Enumerable#{min,min_by,max,max_by} extended to take anakr2014-02-141-0/+8
| | | | | | | | | | | | | | | | | | | | | | | optional argument. (nmin_cmp): New function. (nmin_block_cmp): Ditto (nmin_filter): Ditto. (nmin_i): Ditto. (nmin_run): Ditto. (enum_min): Call nmin_run if the optional argument is given. (nmin_max): Ditto. (nmin_min_by): Ditto. (nmin_max_by): Ditto. * range.c: Range#{min,max} extended to take an optional argument. (range_min): Call range_first if the optional argument is given. (range_max): Call rb_call_super if the optional argument is given. [ruby-core:57111] [Feature #8887] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Have to_h raise on elements that are not key-value pairs [#9239]marcandre2013-12-231-7/+11
| | | | | | * enum.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44354 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Add Array#to_h [Feature #7292]marcandre2013-10-231-0/+27
| | | | | | * enum.c: Add Enumerable#to_h git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test_enum.rb: Make test more precisemarcandre2013-03-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c, enum.c: TypeError in zipnobu2012-09-191-1/+1
| | | | | | | | | | * array.c (take_items), enum.c (enum_zip): raise TypeError at non-enumerable objects, not NoMethodError. [ruby-dev:46145] [Bug #7038] * vm_eval.c (rb_check_block_call): check_funcall variant with block function. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c: move work variables to objects not to let called blocksnobu2012-02-171-0/+19
| | | | | | access stack area out of scope. [Bug #5801] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (slice_before_i): use rb_attr_get to surpress wrong warningnaruse2011-09-241-0/+16
| | | | | | for internal instance variable slicebefore_initial_state. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33324 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add a test.akr2011-01-011-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30442 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_join): remove Enumerable#join. [ruby-core:24786]matz2010-03-131-32/+0
| | | | | | * array.c (ary_join_1): use #to_ary to detect recursive array. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enumerator.c: move implementation of each_slice, each_cons,matz2010-02-031-8/+11
| | | | | | | | | | | | | each_with_object to enum.c. * enum.c (each_slice_i): convert multiple values from yield into an array. * enum.c (each_cons_i): ditto. * enum.c (each_with_object_i): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_each_entry): new method #each_entry to pack valuesmatz2010-02-021-0/+12
| | | | | | | | | | | | | | from yield into an array. * lib/set.rb (Set#merge): use Enumerable#each_entry to implement Set compatible to 1.8 behavior. [ruby-core:27985] * lib/set.rb: replace is_a?(Enumerable) with respond_to?(:each) for duck typing. * lib/set.rb (SortedSet#add): typo fixed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* supress warnings.akr2010-01-251-9/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26418 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_array.rb: add a test for Array#rotate, rotate!.mame2010-01-221-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * test/ruby/test_dir.rb, test/ruby/test_fnmatch.rb: add some tests (for coverage of dir.c). * test/ruby/test_enum.rb: add a test for Enumerable#minmax. * test/ruby/test_enumerator.rb: add some tests for Enumerator#inspect, Enumerator::Generator and Yielder. * test/ruby/test_env.rb: add a test for ENV#index. * test/ruby/test_exception.rb: add some tests (for coverage of error.c). * test/ruby/test_hash.rb: add a test for recursive check. * test/ruby/test_integer.rb: add a test for number of argument of Integer. * test/ruby/test_method.rb: add a test for define_method. * test/ruby/test_module.rb: add a test for constant of included module. * test/ruby/test_proc.rb: add a test for parameters with cfunc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26379 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_enum.rb (test_count): marked as an implementationnobu2009-10-301-8/+10
| | | | | | | specific test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/ruby/test_enum.rb (test_count): test for [ruby-core:24794].nobu2009-10-301-0/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_slice_before): take a pattern if no block given.akr2009-10-021-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e