Cannot wrap a Generator object in an Enumerator and then call next.
-------------------------------------------------------------------
Key: JRUBY-5145
URL: http://jira.codehaus.org/browse/JRUBY-5145
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.5.3
Environment: Linux shadow.lab 2.6.34.7-56.fc13.x86_64 #1 SMP Wed Sep
15 03:36:55 UTC 2010 x86_64 x86_64 x86_64 GNU/Linux
jruby 1.5.3 (ruby 1.8.7 patchlevel 249) (2010-09-28 7ca06d7) (OpenJDK 64-Bit
Server VM 1.6.0_18) [amd64-java]
Reporter: Postmodern
While running specs for my Combinatorics library
(http://github.com/postmodern/combinatorics) I noticed two failures under
JRuby. The failures are connected to creating an Enumerator for a Generator
object, by calling enum_for, then calling #next.
Failures:
1) Array#comprehension should iterate over values from a generator
Failure/Error: a.comprehension.to_a.should == [[0],[1],[2],[3],[4]]
yield called out of block
# generator_internal:248:in `each'
# generator_internal:199:in `_next_element'
# generator_internal:212:in `end?'
# generator_internal:226:in `current'
# generator_internal:217:in `next'
# generator_internal:320:in `next'
# ./lib/combinatorics/list_comprehension.rb:63:in `comprehension'
# ./lib/combinatorics/list_comprehension.rb:63:in `map'
# ./lib/combinatorics/list_comprehension.rb:63:in `comprehension'
# ./spec/list_comprehension_spec.rb:48:in `each'
# ./spec/list_comprehension_spec.rb:48
# :1
2) Array#comprehension should iterate over values from a non-repeating
generator
Failure/Error: a.comprehension.to_a.should == [
yield called out of block
# generator_internal:248:in `each'
# generator_internal:199:in `_next_element'
# generator_internal:212:in `end?'
# generator_internal:226:in `current'
# generator_internal:217:in `next'
# generator_internal:320:in `next'
# ./lib/combinatorics/list_comprehension.rb:63:in `comprehension'
# ./lib/combinatorics/list_comprehension.rb:63:in `map'
# ./lib/combinatorics/list_comprehension.rb:63:in `comprehension'
# ./spec/list_comprehension_spec.rb:61:in `each'
# ./spec/list_comprehension_spec.rb:61
# :1
Reproduction:
require 'generator'
gen = Generator.new { |g| g.yield 1 }
e = gen.enum_for
e.next
Error:
LocalJumpError: yield called out of block
from generator_internal:248:in `each'
from generator_internal:199:in `_next_element'
from generator_internal:212:in `end?'
from generator_internal:226:in `current'
from generator_internal:217:in `next'
from generator_internal:320:in `next'
from (irb):4
Expected result:
1
The given reproduction example behaves expectedly on Ruby 1.9.2, 1.8.7 and
Rubinius.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email