Skip to content

Commit f678b10

Browse files
bjfisheregon
authored andcommitted
Implement Enumerator::Lazy#eager
(cherry picked from commit f8b3866)
1 parent f55e4ba commit f678b10

File tree

5 files changed

+8
-3
lines changed

5 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Compatibility:
3434
* `**kwargs` now accept non-Symbol keys like Ruby 2.7.
3535
* Updated the Unicode Emoji version (#2173, @wildmaples).
3636
* Added `Enumerator::Yielder#to_proc`.
37+
* Implemented `Enumerator::Lazy#eager`.
3738

3839
Performance:
3940

spec/tags/core/enumerator/lazy/eager_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/main/ruby/truffleruby/core/enumerator.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,10 @@ def lazy
310310
self
311311
end
312312

313+
def eager
314+
Enumerator.instance_method(:enum_for).bind(self).call(:each) { size }
315+
end
316+
313317
# TODO: rewind and/or to_a/force behave improperly on outputs of take, drop, uniq, possibly more
314318

315319
alias_method :force, :to_a

test/mri/excludes/TestLazyEnumerator.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
exclude :test_zip_nested, "needs investigation"
1010
exclude :test_initialize, "needs investigation"
1111
exclude :test_take_rewound, "needs investigation"
12+
exclude :test_with_index, "needs investigation"
13+
exclude :test_lazy_to_enum_lazy_methods, "needs investigation"
14+
exclude :test_filter_map, "needs investigation"

test/mri/failing.exclude

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ ruby/test_env.rb # TestEnv#test_aset = core:/core/rubinius/bootstrap/time.rb:28:
167167
ruby/test_file.rb
168168
ruby/test_iseq.rb
169169
ruby/test_iterator.rb # /Users/chrisseaton/Documents/ruby/jruby/test/mri/lib/minitest/unit.rb:1417:in `sort': internal implementation error - NullPointerException null org.truffleruby.runtime.subsystems.TraceManager$4.probeTaggedAs(TraceManager.java:117) (RuntimeError)
170-
ruby/test_lazy_enumerator.rb
171170
ruby/test_m17n_comb.rb # cannot load such file -- etc
172171
ruby/test_marshal.rb # including this causes error in test_objectspace.rb
173172
ruby/test_pipe.rb # tests not excluding

0 commit comments

Comments
 (0)