Make great documentation goal 1.2, and plan the README's reorganisation and the nested-template gaps #33

Open
lilleman wants to merge 966 commits from worktree-todo-relative-dates-exact-counts into main
Showing only changes of commit efbad0f325 - Show all commits
+18 -12
View File
@@ -761,18 +761,24 @@ func TestRepeatedBareTokenOfAHeldNameIsRejected(t *testing.T) {
} }
} }
func TestReadFieldPanicsOnAPathItCannotHold(t *testing.T) { func TestCompileFixesHowEachArmIsRead(t *testing.T) {
a := arm{spelling: "w.x", head: "w", tail: []string{"x"}, path: "w.x"} f, err := New(WithoutShippedData(), WithDataPath(writeData(t, map[string]string{
for name, format := range map[string]string{ "cat": `{"format":"{w} {w} {p.x} {/other.y} {n} {uppercase(n)}","w":["a","b"],"n":["c","d"],"p":{"format":"{x}","x":"1"}}`,
"unheld arm with a path": `{"format":"{w}","w":{"format":"{x}","x":"1"}}`, "other": `{"format":"{y}","y":"2"}`,
"held arm with no hold": `{"format":"{w.x}","w":{"format":"{x}","x":"1"}}`, })))
} { if err != nil {
tm, ok := compiled(t, format).(*template) t.Fatal(err)
if !ok { }
t.Fatal("not a template") tm, ok := f.root.children["cat"].(*template)
if !ok {
t.Fatal("cat is not a template")
}
want := map[string]armKind{"/other.y": refPathRead, "n": heldRead, "p.x": heldRead, "w": freshRead}
for _, o := range tm.compiled.ops {
for _, a := range append(o.arms, o.operands...) {
if a.kind != want[a.spelling] {
t.Errorf("{%s} compiles to kind %d, want %d", a.spelling, a.kind, want[a.spelling])
}
} }
mustPanic(t, name, func() {
readField(engine(1).rand, tm, nil, renderScope{draws: &renderDraws{}}, a)
})
} }
} }