Test what stability round 1 found untested: a parent's zero-weight rows, a frame per draw of a choice item, ignored flags against the run without them, two leading slashes, and an option too close to 0

This commit is contained in:
2026-10-08 12:11:14 +02:00
committed by Lillem4n
parent 2c2cbbb633
commit c337dc4436
9 changed files with 96 additions and 58 deletions
+17 -17
View File
@@ -37,21 +37,20 @@ func TestOneItemChoiceIsItsItem(t *testing.T) {
func TestAPartWithNoEffectRendersAsWithoutIt(t *testing.T) {
for long, short := range map[string]string{
`{"format":"Malmö"}`: `"Malmö"`,
`{"format":"{digits(3)}"}`: `"{digits(3)}"`,
`[{"format":"a","weight":1},"b"]`: `["a","b"]`,
`[{"format":"a","weight":0},"b"]`: `"b"`,
`{"format":"a","weight":2}`: `"a"`,
`{"format":"a","weight":0}`: `"a"`,
`{"format":"{x}","x":{"format":"a","weight":2}}`: `{"format":"{x}","x":"a"}`,
`[{"format":"a","weight":2}]`: `"a"`,
`{"format":"{x}","x":["a","b"],"repeat":1}`: `{"format":"{x}","x":["a","b"]}`,
`{"format":"{x}","x":["a","b"],"separator":","}`: `{"format":"{x}","x":["a","b"]}`,
`{"format":"{x}","x":["a","b"],"repeat":2,"separator":""}`: `{"format":"{x}","x":["a","b"],"repeat":2}`,
`{"format":"","n":{"format":"{x}","x":["1","2"],"datatype":"string"}}`: `{"format":"","n":{"format":"{x}","x":["1","2"]}}`,
`{"format":"{n}","repeat":2,"n":{"format":"1","datatype":"integer"}}`: `{"format":"{n}","repeat":2,"n":"1"}`,
`[{"format":"1","datatype":"integer"},"x"]`: `["1","x"]`,
`{"format":"{word as w}x","word":["a","b"]}`: `"x"`,
`{"format":"Malmö"}`: `"Malmö"`,
`{"format":"{digits(3)}"}`: `"{digits(3)}"`,
`[{"format":"a","weight":1},"b"]`: `["a","b"]`,
`[{"format":"a","weight":0},"b"]`: `"b"`,
`{"format":"a","weight":2}`: `"a"`,
`{"format":"a","weight":0}`: `"a"`,
`{"format":"{x}","x":{"format":"a","weight":2}}`: `{"format":"{x}","x":"a"}`,
`[{"format":"a","weight":2}]`: `"a"`,
`{"format":"{x}","x":["a","b"],"repeat":1}`: `{"format":"{x}","x":["a","b"]}`,
`{"format":"{x}","x":["a","b"],"separator":","}`: `{"format":"{x}","x":["a","b"]}`,
`{"format":"{x}","x":["a","b"],"repeat":2,"separator":""}`: `{"format":"{x}","x":["a","b"],"repeat":2}`,
`{"format":"{n}","repeat":2,"n":{"format":"1","datatype":"integer"}}`: `{"format":"{n}","repeat":2,"n":"1"}`,
`[{"format":"1","datatype":"integer"},"x"]`: `["1","x"]`,
`{"format":"{word as w}x","word":["a","b"]}`: `"x"`,
`null`: `""`,
`{"format":"{p}","p":{"format":"{x}","x":[null,"a"]}}`: `{"format":"{p}","p":{"format":"{x}","x":["","a"]}}`,
`"{int(5,5)}"`: `"5"`,
@@ -65,8 +64,9 @@ func TestAPartWithNoEffectRendersAsWithoutIt(t *testing.T) {
} {
sameRenders(t, long, short)
}
if r := compiled(t, `{"format":"","n":{"format":"1","datatype":"string"}}`).(*template); !r.isRecord || *r.fields["n"].(*template).datatype != DataTypeString {
t.Error("a column of datatype string is no string column of a record")
r, err := shipped(t).NewRecordTemplate(`{"format":"","n":{"format":"{x}","x":["1","2"],"datatype":"string"}}`)
if err != nil || r.Fake().Columns()[0].DataType != DataTypeString {
t.Errorf("a column of datatype string = %v, want a string column", err)
}
if got := mustRender(t, engine(1), `"{date(1990-01-01,1990-12-31,'15:04')}"`); !regexp.MustCompile(`^\d\d:\d\d$`).MatchString(got) {
t.Errorf("date with a clock-only layout = %q, want a clock", got)