File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,10 @@ abstract type AbstractNetworkIterator end
1212islaststep (iterator:: AbstractNetworkIterator ) = state (iterator) >= length (iterator)
1313
1414function Base. iterate (iterator:: AbstractNetworkIterator , init = true )
15- islaststep (iterator) && return nothing
15+ # The assumption is that first "increment!" is implicit, therefore we must skip the
16+ # the termination check for the first iteration, i.e. `AbstractNetworkIterator` is not
17+ # defined when length < 1,
18+ init || islaststep (iterator) && return nothing
1619 # We seperate increment! from step! and demand that any AbstractNetworkIterator *must*
1720 # define a method for increment! This way we avoid cases where one may wish to nest
1821 # calls to different step! methods accidentaly incrementing multiple times.
Original file line number Diff line number Diff line change 4949 import . TestIteratorUtils
5050
5151 @testset " `AbstractNetworkIterator` Interface" begin
52+
53+ @testset " Edge cases" begin
54+ TI = TestIteratorUtils. TestIterator (1 , 1 , [])
55+ cb = []
56+ @test islaststep (TI)
57+ for _ in TI
58+ @test islaststep (TI)
59+ push! (cb, state (TI))
60+ end
61+ @test length (cb) == 1
62+ @test length (TI. output) == 1
63+ @test only (cb) == 1
64+ end
5265 TI = TestIteratorUtils. TestIterator (1 , 4 , [])
5366
5467 @test ! islaststep ((TI))
You can’t perform that action at this time.
0 commit comments