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
2 changed files with 23 additions and 4 deletions
Showing only changes of commit 9e392d02fd - Show all commits
+12 -4
View File
@@ -75,10 +75,11 @@ func TestAPartWithNoEffectRendersAsWithoutIt(t *testing.T) {
func TestAJSONNumberOrBooleanInARecordColumnIsRefused(t *testing.T) {
for src, want := range map[string][]string{
`{"format":"","n":5}`: {`"5"`, `{"format":"5","datatype":"integer"}`},
`{"format":"","n":1.50}`: {`"1.50"`, `{"format":"1.50","datatype":"number"}`},
`{"format":"","b":true}`: {`"true"`, `{"format":"true","datatype":"boolean"}`},
`{"format":"","n":[5,"x"]}`: {`"5"`, `{"format":"5","datatype":"integer"}`},
`{"format":"","n":5}`: {`"5"`, `{"format":"5","datatype":"integer"}`},
`{"format":"","n":1.50}`: {`"1.50"`, `{"format":"1.50","datatype":"number"}`},
`{"format":"","b":true}`: {`"true"`, `{"format":"true","datatype":"boolean"}`},
`{"format":"","n":12345678901234567890}`: {`"12345678901234567890"`, `{"format":"12345678901234567890","datatype":"number"}`},
`{"format":"","n":[5,"x"]}`: {`"5"`, `{"format":"5","datatype":"integer"}`},
} {
_, err := resolved(t, src)
for _, w := range want {
@@ -89,6 +90,13 @@ func TestAJSONNumberOrBooleanInARecordColumnIsRefused(t *testing.T) {
}
}
func TestAJSONNumberNoDatatypeHoldsIsOfferedAsTextAlone(t *testing.T) {
_, err := resolved(t, `{"format":"","n":1e400}`)
if err == nil || !strings.Contains(err.Error(), `write "1e400" for text`) || strings.Contains(err.Error(), `"datatype"`) {
t.Errorf("compile(1e400 in a column) = %v, want text offered alone", err)
}
}
func TestAJSONNumberOrBooleanIsItsText(t *testing.T) {
f := newGenerator(t, writeData(t, map[string]string{
"n": `{"format":"{x}","x":{"format":"{a} {b} {c} {d}","a":5,"b":1.50,"c":12345678901234567890,"d":true}}`,
+11
View File
@@ -253,6 +253,17 @@ func TestFakeStructTakesTheDatatypeItsGoTypeSets(t *testing.T) {
}
}
func TestFakeStructTypesABareNumberOrBooleanByItsGoType(t *testing.T) {
v := struct {
N int `fake:"[5, 6]"`
B bool `fake:"[true, false]"`
S string `fake:"[7.50]"`
}{}
if err := structData(t).FakeStruct(&v); err != nil || (v.N != 5 && v.N != 6) || v.S != "7.50" {
t.Errorf("FakeStruct = %+v, %v, want each value typed by its field", v, err)
}
}
func TestFakeStructWithNoTagsFillsNothing(t *testing.T) {
v := struct{ A string }{A: "kept"}
if err := structData(t).FakeStruct(&v); err != nil || v.A != "kept" {