Bug in generators
-----------------
Key: JRUBY-1635
URL: http://jira.codehaus.org/browse/JRUBY-1635
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1b1, JRuby 1.0.2, JRuby 1.0.1
Environment: Gentoo (2.6.22), Sun J2SE 1.5.0.13
Reporter: Jordan Callicoat
Attachments: test.rb
Generators don't consume all of their values. The EOFError is raised one
element prior to the last one.
Reproducible:
always
Tested versions:
ruby 1.8.5 (2007-11-28 rev 3841) [i386-jruby1.0] <- built on my system
ruby 1.8.5 (2007-11-01 rev 4810) [i386-jruby1.0.2] <- official binary
ruby 1.8.5 (2007-11-01 rev 4842) [i386-jruby1.1b1] <- official binary
Steps to reproduce:
run test.rb
==== test.rb ====
require 'generator'
generators = [[1,2,3], [4,5,6]].map { | a |
Generator.new(a)
}
while 1 # let the EOFError trip so we know Generator
# thinks it has consumed all the elements
p generators.map { |g| g.next }
end
=============
Expected results:
[1, 4]
[2, 5]
[3, 6]
/usr/lib/ruby/1.8/generator.rb:128:in `next': no more elements available
(EOFError)
from test.rb:7
from test.rb:7:in `map'
from test.rb:7
Actual results:
[1, 4]
[2, 5]
:-1: End of file reached (EOFError)
from :-1:in `map'
from :-1
Other details:
$ uname -a
Linux sageware 2.6.22-gentoo-r9 #2 SMP Wed Nov 21 02:01:38 CST 2007 i686 AMD
Athlon(tm) XP 1500+ AuthenticAMD GNU/Linux
$ java-config -v
java version "1.5.0_13"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05)
Java HotSpot(TM) Client VM (build 1.5.0_13-b05, mixed mode)
--
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