Answer prose round 1: readName and readField say one idea a sentence and name what each pick and read is, and the test's message names whose b it checks
This commit is contained in:
@@ -141,11 +141,12 @@ func (sc renderScope) frameOf(scope *nameScope) *pickFrame {
|
||||
return nil
|
||||
}
|
||||
|
||||
// readName reads a from its name's pick in the frame rendering the name's scope. A read entering
|
||||
// another category takes the frames of the name scopes there from the pick's memo (enter), and
|
||||
// renderFrame finds them and opens none, so every read of the pick reads one pick of each name
|
||||
// bound there: {a.street} and {a.postal-code} in data/sv_SE/address.json read one pick of the
|
||||
// name l that data/geo/SE/address.json binds.
|
||||
// readName reads the arm a from the pick of its name, held in the frame of the name's scope.
|
||||
// When the pick renders another category, enter takes that category's frames from the pick's
|
||||
// memo, and renderFrame finds them and opens no new one.
|
||||
// So every read through one pick sees one pick of each name the other category binds:
|
||||
// {a.street} and {a.postal-code} in data/sv_SE/address.json read one pick of the name l
|
||||
// that data/geo/SE/address.json binds.
|
||||
func readName(s *drawstate.State, sc renderScope, a arm) readValue {
|
||||
f := sc.frameOf(a.named.scope)
|
||||
if f == nil {
|
||||
|
||||
+1
-1
@@ -340,7 +340,7 @@ func TestAFreshReadInsideANamedPickSharesNoValueWithIt(t *testing.T) {
|
||||
for i := 0; i < 100; i++ {
|
||||
got := mustRender(t, f, src)
|
||||
if m := want.FindStringSubmatch(got); m == nil || m[1] != m[2] {
|
||||
t.Fatalf("draw %d = %q, want p.a's c drawn afresh and its b read from p's pick", i, got)
|
||||
t.Fatalf("draw %d = %q, want c's b from x, y or z, and p.a's b equal to {p.a.b}", i, got)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,11 +142,12 @@ func expand(s *drawstate.State, t *template, sc renderScope) string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// readField renders one arm of a token. A read of a name, or of a level a read of the name
|
||||
// rendering addresses, is kept in that name's pick; every other read draws afresh, so {word}
|
||||
// {word} draws twice and {p.a} {p.b} reads two draws of p. A fresh read leaves the pick: a read
|
||||
// below it would key the pick's memo by sc.pickKey, the level the pick rendered, so it and the
|
||||
// pick would read one value for two nodes.
|
||||
// readField renders one arm of a token. A read is kept in a name's pick when it reads the name, or
|
||||
// a level that a read of the name being rendered addresses; every other read draws afresh, so
|
||||
// {word} {word} draws twice and {p.a} {p.b} reads two draws of p.
|
||||
// A fresh read clears sc.pick. Kept, a read nested in the fresh one would key the pick's memo by
|
||||
// sc.pickKey, the path from the name to what the pick renders, and share a value with a different
|
||||
// node at that path.
|
||||
func readField(s *drawstate.State, t *template, sc renderScope, a arm) readValue {
|
||||
switch {
|
||||
case a.kind == namedRead:
|
||||
|
||||
Reference in New Issue
Block a user