summaryrefslogtreecommitdiff
path: root/test/ruby/test_enumerator.rb
AgeCommit message (Collapse)Author
2019-06-02Make size on an infinite each_slice enumerator return InfinityJeremy Evans
Fixes [Bug #15889]
2019-05-23Adding Enumerable#filter_mapAlfonso Jiménez
[Feature #15323] Closes: https://github.com/ruby/ruby/pull/2017
2019-03-11Implement Enumerator::Yielder#to_procknu
A Yielder object can now be directly passed to another method as a block argument. ```ruby enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24enumerator.c: fix inspect with the last empty hashnobu
[ruby-core:90685] [Bug #15455] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-24Implement Enumerator#+ and Enumerable#chain [Feature #15144]knu
They return an Enumerator::Chain object which is a subclass of Enumerator, which represents a chain of enumerables that works as a single enumerator. ```ruby e = (1..3).chain([4, 5]) e.to_a #=> [1, 2, 3, 4, 5] e = (1..3).each + [4, 5] e.to_a #=> [1, 2, 3, 4, 5] ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22Set the size of a new enumerator created by Enumerator#each with arguments ↵knu
to nil When each() takes arguments, it is never safe to assume that the iteration would repeat the same number of times as with each() without any argument. Actually, there is no way to get the exact number, so the size should be set to nil to denote that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-18Tests of Enumerator::Yielder#yield with multiple argumentsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06enumerator.c: Introduce Enumerator::ArithmeticSequencemrkn
This commit introduces new core class Enumerator::ArithmeticSequence. Enumerator::ArithmeticSequence is a subclass of Enumerator, and represents a number generator of an arithmetic sequence. After this commit, Numeric#step and Range#step without blocks returned an ArithmeticSequence object instead of an Enumerator. This class introduces the following incompatibilities: - You can create a zero-step ArithmeticSequence, and its size is not ArgumentError, but Infinity. - You can create a negative-step ArithmeticSequence from a range. [ruby-core:82816] [Feature #13904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13test_enumerator.rb: duplicate assertionsnobu
* test/ruby/test_enumerator.rb (test_uniq): remove assertions which ared duplicate of lazy enumerator tests in test_lazy_enumerator.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13Bug Fix Enumerator::Lazy#uniq state for multiple callnobu
* enumerator.c (lazy_uniq_i): create new hash for each calls. [Fix GH-1820] Currently 2.5.0-preview1 :001 > arr = (0..100).lazy.uniq{|i| i % 10} => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..100>:uniq> 2.5.0-preview1 :002 > arr.to_a => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2.5.0-preview1 :003 > arr.to_a => [] Expected arr.to_a to always return same output From: Anmol Chopra <anmolchopra@rocketbox.in> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-25Add a new #filter alias for #selecteregon
* In Enumerable, Enumerator::Lazy, Array, Hash and Set [Feature #13784] [ruby-core:82285] * Share specs for the various #select#select! methods and reuse them for #filter/#filter!. * Add corresponding filter tests for select tests. * Update NEWS. [Fix GH-1824] From: Alexander Patrick <adp90@case.edu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-12Add FrozenError as a subclass of RuntimeErrorshyouhei
FrozenError will be used instead of RuntimeError for exceptions raised when there is an attempt to modify a frozen object. The reason for this change is to differentiate exceptions related to frozen objects from generic exceptions such as those generated by Kernel#raise without an exception class. From: Jeremy Evans <code@jeremyevans.net> Signed-off-by: Urabe Shyouhei <shyouhei@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-05enum.c: check argument firstnobu
* enum.c (enum_cycle_size): check an argument before the size of the receiver, if it is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-05Fix size on Enumerable#cycle when the size is 0 [Bug #14082].marcandre
Patch by Kenichi Kamiya git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-07-20enumerator.c: Enumerator::Lazy#uniqnobu
* enumerator.c (lazy_uniq): new method Enumerator::Lazy#uniq. [Feature #11090] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-02-19test/ruby: suppress parser warningsnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-16Add frozen_string_literal: false for all filesnaruse
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
2015-10-22Kernel#loop returns the result value of a finished iteratorknu
* vm_eval.c (rb_f_loop): When a loop is stopped by a StopIteration exception, return what the enumerator has returned instead of nil. [ruby-core:71133] [Feature #11498] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-28preserve encodings in error messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-13* test/lib/envutil.rb: Moved from test/ruby/.akr
* test/lib/find_executable.rb: Ditto. * test/lib/memory_status.rb: Ditto. * test/lib/test/unit.rb: require envutil. * test/: Don't require envutil in test files. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-10merge GH-558nobu
* test/ruby/test_enumerator.rb (test_iterators): fix test for hash iterators. [Fixes GH-558] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-14Additional test coverage to Enumerator#peek.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-07hash.c: rb_hash_reject without dupnobu
* hash.c (rb_hash_reject): copy unrejected elements only to new hash, so that the change on the original receiver can affect. [ruby-core:58914] [Bug #9223] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44047 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-30enumerator.c: should not store local variable addressnobu
* enumerator.c (enumerator_with_index): should not store local variable address to memoise the arguments. it is invalidated after the return. [ruby-core:58692] [Bug #9178] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27* enumerator.c: Allow Enumerator size argument to be any callable.marcandre
Patch by Avdi Grimm. [bug #8641] [ruby-core:56032] [fix GH-362] * test/ruby/test_enumerator.rb: Test for above git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29Add a frozenness check to Enumerator::Generator#initialize.knu
* enumerator.c (generator_init): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-29Add a frozenness check to Enumerator#initialize.knu
* enumerator.c (enumerator_init): Add a frozenness check to prevent a frozen Enumerator object from being reinitialized with a different enumerable object. This is the least we should do, and more fixes will follow. [Fixes GH-368] Patch by Kenichi Kamiya. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-18enumerator.c: use VALUEnobu
* enumerator.c (inspect_enumerator): use VALUE instead of mere char* by using rb_sprintf() and rb_id2str(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-11* enumerator.c (enumerator_with_index): try to convert given offset tonaruse
integer. fix bug introduced in r39594. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-03-05enumerator.c: allow Bignum for with_indexnobu
* enumerator.c (enumerator_with_index_i): allow Bignum as offset, to get rid of conversion exception and integer overflow. [ruby-dev:47131] [Bug #8010] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24Fix tests of rb_warning().knu
* test/ruby/envutil.rb (Test::Unit::Assertions#assert_warning) (Test::Unit::Assertions#assert_warn), test/ruby/envutil.rb, test/ruby/test_enumerator.rb, test/ruby/test_io_m17n.rb, test/ruby/test_regexp.rb, test/ruby/test_syntax.rb: assert_warn() and assert_warning() are reversed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37836 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-10Revert of 37541 "* test/ruby/test_enumerator.rb: Add test to shed light upon ↵marcandre
the bug" [#7298] This reverts commit 0ab21f9572d5d5f76b908aaf3381cde32a64c4c8. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-07* test/ruby/test_enumerator.rb: Add test to shed light upon the bugayumin
which made by r37498. See http://bugs.ruby-lang.org/issues/7298 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37541 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* string.c: Support for String#{each_byte,each_char,each_codepoint}.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (int_dotimes): Support for Integer#times.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (int_upto, int_downto): Support for Integer#{down|up}to.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* range.c: Support for range.step.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* numeric.c (num_step): Support for Numeric#step.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* struct.c: Support for Struct's enumerators #sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* hash.c: Support for enumerators created by ENV:marcandre
each, each_value, ... [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* hash.c: Support for enumerators created by Hash:marcandre
delete_if, reject!, ... [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* enum.c (enum_cycle): Support for Enumerable#cycle.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37510 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* enum.c (enum_each_cons): Support for Enumerable#each_cons.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* enum.c (enum_each_slice): Support for Enumerable#each_slice.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37508 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* enum.c: Support for enumerators created by Enumerable with forwarding:marcandre
find_all, reject, ... [Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* vm_eval.c (rb_f_loop): Support for loop.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37506 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* array.c (rb_ary_cycle): Support for Array#cycle.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* array.c (rb_ary_repeated_combination): Support for repeated_combination.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* array.c (rb_ary_repeated_permutation): Support for repeated_permutation.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-06* array.c (rb_ary_combination): Support for Array#combination.sizemarcandre
[Feature #6636] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e