Share one read fold across each oracle's corpus, as the draw fence does
This commit is contained in:
+5
-3
@@ -64,10 +64,11 @@ func TestReplayPairsFindsWhatAWholeReplayFinds(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
compared := 0
|
compared := 0
|
||||||
|
fold := newReadFold()
|
||||||
for _, root := range roots {
|
for _, root := range roots {
|
||||||
compared += wantPairsFindAll(t, root.label, surveyRender(root.t).reads)
|
compared += wantPairsFindAll(t, root.label, surveyRender(fold, root.t).reads)
|
||||||
if root.t.isRecord && len(root.t.fields) > 0 {
|
if root.t.isRecord && len(root.t.fields) > 0 {
|
||||||
compared += wantPairsFindAll(t, root.label+" as a record", surveyColumns(root.t, sortedNames(root.t.fields)).reads)
|
compared += wantPairsFindAll(t, root.label+" as a record", surveyColumns(fold, root.t, sortedNames(root.t.fields)).reads)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if compared == 0 {
|
if compared == 0 {
|
||||||
@@ -81,6 +82,7 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) {
|
|||||||
t.Fatalf("New = %v", err)
|
t.Fatalf("New = %v", err)
|
||||||
}
|
}
|
||||||
var reads []pathRead
|
var reads []pathRead
|
||||||
|
fold := newReadFold()
|
||||||
_ = walkNodes(f.root.children, func(_ string, n node) error {
|
_ = walkNodes(f.root.children, func(_ string, n node) error {
|
||||||
tb, isTable := n.(*table)
|
tb, isTable := n.(*table)
|
||||||
if !isTable || tb.keyIndex < 0 || tb.familyRoot().path != "region" {
|
if !isTable || tb.keyIndex < 0 || tb.familyRoot().path != "region" {
|
||||||
@@ -95,7 +97,7 @@ func TestReplayPairsFindsWhatAWholeReplayOfSelectedRowsFinds(t *testing.T) {
|
|||||||
if !isTemplate {
|
if !isTemplate {
|
||||||
t.Fatalf("NewTemplate(%s) compiled to %T", tb.selectorSpelling(r), inline.n)
|
t.Fatalf("NewTemplate(%s) compiled to %T", tb.selectorSpelling(r), inline.n)
|
||||||
}
|
}
|
||||||
reads = append(reads, surveyRender(root).reads...)
|
reads = append(reads, surveyRender(fold, root).reads...)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
+8
-9
@@ -10,8 +10,9 @@ func TestEveryReadARenderMakesIsGathered(t *testing.T) {
|
|||||||
f := fenceCorpus(t)
|
f := fenceCorpus(t)
|
||||||
roots := fenceRoots(t, f)
|
roots := fenceRoots(t, f)
|
||||||
traced := 0
|
traced := 0
|
||||||
|
fold := newReadFold()
|
||||||
for _, root := range roots {
|
for _, root := range roots {
|
||||||
traced += wantGathered(t, root.label, surveyRender(root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) })
|
traced += wantGathered(t, root.label, surveyRender(fold, root.t).reads, func(trace renderTrace) { renderRoot(f.rand, root.t, trace) })
|
||||||
if !root.t.isRecord || len(root.t.fields) == 0 {
|
if !root.t.isRecord || len(root.t.fields) == 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -19,7 +20,7 @@ func TestEveryReadARenderMakesIsGathered(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("%s: recordOf = %v", root.label, err)
|
t.Fatalf("%s: recordOf = %v", root.label, err)
|
||||||
}
|
}
|
||||||
traced += wantGathered(t, root.label+" as a record", surveyColumns(root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) })
|
traced += wantGathered(t, root.label+" as a record", surveyColumns(fold, root.t, sortedNames(root.t.fields)).reads, func(trace renderTrace) { renderRecordRoot(f.rand, root.t, columns, trace) })
|
||||||
}
|
}
|
||||||
if traced == 0 {
|
if traced == 0 {
|
||||||
t.Error("no render traced a reference read, so the comparison proved nothing")
|
t.Error("no render traced a reference read, so the comparison proved nothing")
|
||||||
@@ -125,7 +126,7 @@ func TestReadSurveyWalksACellByEveryRoute(t *testing.T) {
|
|||||||
t.Fatalf("r is a %T, want a template", g.children["r"])
|
t.Fatalf("r is a %T, want a template", g.children["r"])
|
||||||
}
|
}
|
||||||
var pinned, whole bool
|
var pinned, whole bool
|
||||||
for _, read := range surveyRender(r).reads {
|
for _, read := range surveyRender(newReadFold(), r).reads {
|
||||||
if read.a.path != "/z" {
|
if read.a.path != "/z" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -157,24 +158,22 @@ func TestReadSurveyReportsAPinClashAsAnError(t *testing.T) {
|
|||||||
if !isTemplate {
|
if !isTemplate {
|
||||||
t.Fatalf("r is a %T, want a template", g.children["r"])
|
t.Fatalf("r is a %T, want a template", g.children["r"])
|
||||||
}
|
}
|
||||||
if err := surveyRender(r).check(); err == nil || !strings.Contains(err.Error(), "two rows of") {
|
if err := surveyRender(newReadFold(), r).check(); err == nil || !strings.Contains(err.Error(), "two rows of") {
|
||||||
t.Errorf("check = %v, want y[a]'s row of x clashing with x[2] named, whatever order the fences run in", err)
|
t.Errorf("check = %v, want y[a]'s row of x clashing with x[2] named, whatever order the fences run in", err)
|
||||||
}
|
}
|
||||||
n, isTemplate := g.children["n"].(*template)
|
n, isTemplate := g.children["n"].(*template)
|
||||||
if !isTemplate {
|
if !isTemplate {
|
||||||
t.Fatalf("n is a %T, want a template", g.children["n"])
|
t.Fatalf("n is a %T, want a template", g.children["n"])
|
||||||
}
|
}
|
||||||
if err := surveyRender(n).check(); err == nil || !strings.HasPrefix(err.Error(), "{f} with {/x[2].v}: x[1] and x[2] are two rows of x") {
|
if err := surveyRender(newReadFold(), n).check(); err == nil || !strings.HasPrefix(err.Error(), "{f} with {/x[2].v}: x[1] and x[2] are two rows of x") {
|
||||||
t.Errorf("check = %v, want the clash below {f} named by the route the root reaches it by", err)
|
t.Errorf("check = %v, want the clash below {f} named by the route the root reaches it by", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func surveyRender(t *template) *readSurvey {
|
func surveyRender(f *readFold, t *template) *readSurvey {
|
||||||
f := newReadFold()
|
|
||||||
return survey(f.rootReads(t), t.link.drawGroupKey)
|
return survey(f.rootReads(t), t.link.drawGroupKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
func surveyColumns(t *template, columns []string) *readSurvey {
|
func surveyColumns(f *readFold, t *template, columns []string) *readSurvey {
|
||||||
f := newReadFold()
|
|
||||||
return survey(f.columnReads(t, columns), t.link.drawGroupKey)
|
return survey(f.columnReads(t, columns), t.link.drawGroupKey)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user