forked from jruby/jruby
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix JRUBY-6892: Calling #drop on an Enumerator doesn't work properly
When "drop" is called on an Enumerator, the memory locations for the members of the return value were reused. This resulted in a wrong result that the ticket describes. We address the problem by calling dup() whenever appropriate.
- Loading branch information
Showing
2 changed files
with
14 additions
and
1 deletion.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
spec/regression/JRUBY-6892_drop_on_enumerator_oddity_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require 'rspec' | ||
|
||
describe "Enumerable#drop" do | ||
context "when called on an Enumerator" do | ||
let(:enumerator) { (1..10).to_a.each_slice(3)} | ||
it "should behave as if it is called on an Enumerable" do | ||
enumerator.drop(2).should == [[7,8,9],[10]] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters