Simplify Nexter interface

This change allows a Nexter to be used in the same manner as a scanner
using a for graph.Next(it) {} construction.

It is important that graph.Next(it) and any associated it.Result() calls
operate on the same iterator.
This commit is contained in:
kortschak 2014-08-01 09:15:02 +09:30
parent f8e28e066e
commit b1a70d99aa
31 changed files with 168 additions and 233 deletions

View file

@ -114,10 +114,10 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
outerAnd.AddSubIterator(fixed)
outerAnd.AddSubIterator(hasa)
val, ok := outerAnd.Next()
if !ok {
if !outerAnd.Next() {
t.Error("Expected one matching subtree")
}
val := outerAnd.Result()
if ts.NameOf(val) != "C" {
t.Errorf("Matching subtree should be %s, got %s", "barak", ts.NameOf(val))
}
@ -138,8 +138,7 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) {
t.Errorf("Unexpected result, got:%q expect:%q", got, expect)
}
val, ok = outerAnd.Next()
if ok {
if outerAnd.Next() {
t.Error("More than one possible top level output?")
}
}
@ -190,8 +189,7 @@ func TestRemoveTriple(t *testing.T) {
hasa := iterator.NewHasA(ts, innerAnd, quad.Object)
newIt, _ := hasa.Optimize()
_, ok := graph.Next(newIt)
if ok {
if graph.Next(newIt) {
t.Error("E should not have any followers.")
}
}