Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join calls done() twice on the iterables #9178

Closed
lucasb-eyer opened this issue Nov 27, 2014 · 3 comments · Fixed by #9179
Closed

join calls done() twice on the iterables #9178

lucasb-eyer opened this issue Nov 27, 2014 · 3 comments · Fixed by #9179

Comments

@lucasb-eyer
Copy link
Contributor

As noticed by @ivarne in #9159. Here is a possible unittest for it:

# issue #XXX `join` calls `done()` twice on the iterables                                           
let                                                                                                 
    type JoinTest                                                                                   
        nnext::Int64                                                                                
        ndone::Int64                                                                                
    end                                                                                             
    import Base.start, Base.done, Base.next                                                         
    function Base.start(jt::JoinTest) jt.nnext=0 ; jt.ndone=0 ; 0 end                               
    function Base.done(jt::JoinTest, n) jt.ndone += 1 ; n > 3 end                                   
    function Base.next(jt::JoinTest, n) jt.nnext += 1 ; "$(jt.nnext),$(jt.ndone)", n+1 end          

    @test join(JoinTest(0,0), ";") == "1,1;2,2;3,3;4,4"                                             
end                                                                                                 
@ivarne
Copy link
Member

ivarne commented Nov 27, 2014

That works! (or rather it fails)

I'll try to fix the join implementation.

@ivarne
Copy link
Member

ivarne commented Nov 27, 2014

Hmm... This will be our first explicit test for join. It's probably time!

ivarne added a commit to ivarne/julia that referenced this issue Nov 27, 2014
Some iterators might mutate their state in the `done()` method (eg Task)
and that will give wrong results when `join` calls `done` twice per
iteration. This fixes that, and add a few tests to `join` that were
missing.

Fixes JuliaLang#9178
@StefanKarpinski
Copy link
Member

Thanks guys. I wrote join a long time ago before we were in the habit of writing tests for everything.

ivarne added a commit that referenced this issue Dec 6, 2014
Some iterators might mutate their state in the `done()` method (eg Task)
and that will give wrong results when `join` calls `done` twice per
iteration. This fixes that, and add a few tests to `join` that were
missing.

Fixes #9178

ref: #9179
(cherry picked from commit 8bd554c)

Conflicts:
	test/strings.jl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants