Fix Err fallout for graph/iterator.Not iterator
This commit is contained in:
parent
1181e76ab0
commit
c156fd6b1b
2 changed files with 25 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ type Not struct {
|
||||||
primaryIt graph.Iterator
|
primaryIt graph.Iterator
|
||||||
allIt graph.Iterator
|
allIt graph.Iterator
|
||||||
result graph.Value
|
result graph.Value
|
||||||
|
err error
|
||||||
runstats graph.IteratorStats
|
runstats graph.IteratorStats
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -87,9 +88,16 @@ func (it *Not) Next() bool {
|
||||||
return graph.NextLogOut(it, curr, true)
|
return graph.NextLogOut(it, curr, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err := graph.Err(it.allIt); err != nil {
|
||||||
|
it.err = err
|
||||||
|
}
|
||||||
return graph.NextLogOut(it, nil, false)
|
return graph.NextLogOut(it, nil, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (it *Not) Err() error {
|
||||||
|
return it.err
|
||||||
|
}
|
||||||
|
|
||||||
func (it *Not) Result() graph.Value {
|
func (it *Not) Result() graph.Value {
|
||||||
return it.result
|
return it.result
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package iterator
|
package iterator
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -42,3 +43,19 @@ func TestNotIteratorBasics(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNotIteratorErr(t *testing.T) {
|
||||||
|
retErr := errors.New("unique")
|
||||||
|
allIt := newTestIterator(false, retErr)
|
||||||
|
|
||||||
|
toComplementIt := NewFixed(Identity)
|
||||||
|
|
||||||
|
not := NewNot(toComplementIt, allIt)
|
||||||
|
|
||||||
|
if not.Next() != false {
|
||||||
|
t.Errorf("Not iterator did not pass through initial 'false'")
|
||||||
|
}
|
||||||
|
if not.Err() != retErr {
|
||||||
|
t.Errorf("Not iterator did not pass through underlying Err")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue