Test that each spelling goal 5.7 no longer refuses loads as its shorter form

This commit is contained in:
2026-10-07 22:23:18 +02:00
committed by Lillem4n
parent 4930a2ac8d
commit 91b65e3ded
13 changed files with 214 additions and 143 deletions
+1 -4
View File
@@ -17,7 +17,7 @@ func TestLiteralSaysWhichDatatypesItsTextIs(t *testing.T) {
{"1.5", [datatype.Count]bool{datatype.Integer: true, datatype.Boolean: true}},
{"true", [datatype.Count]bool{datatype.Integer: true, datatype.Number: true}},
{"007", [datatype.Count]bool{datatype.Integer: true, datatype.Number: true, datatype.Boolean: true}},
{"-0", [datatype.Count]bool{datatype.Integer: true, datatype.Number: true, datatype.Boolean: true}},
{"-0", [datatype.Count]bool{datatype.Boolean: true}},
} {
v := Literal(c.text)
for d := datatype.Integer; d < datatype.Count; d++ {
@@ -26,9 +26,6 @@ func TestLiteralSaysWhichDatatypesItsTextIs(t *testing.T) {
}
}
}
if v := Literal("-0"); v.Not[datatype.Integer] != `"-0" is zero written with a sign; write "0"` {
t.Errorf("Literal(-0) = %q, want the unsigned spelling named", v.Not[datatype.Integer])
}
}
func TestOrKeepsTheBoundsOfBothAndTheFirstReason(t *testing.T) {
+11 -2
View File
@@ -34,10 +34,9 @@ func TestParseRefuses(t *testing.T) {
want string
}{
{"no header", "", Options{}, "no header line"},
{"one row", "a\n1\n", Options{}, "has one row"},
{"no rows", "a\n", Options{}, "has no rows below its header"},
{"a short row", "a\tb\n1\t2\n3\n", Options{}, "line 3 has fewer cells"},
{"a repeated key", "k\nx\nx\n", Options{Key: "k"}, `key "x" repeats line 2`},
{"the key named as name", "k\nx\ny\n", Options{Key: "k", Name: "k"}, "name names the key column"},
{"a weight of zero", "k\tw\nx\t1\ny\t0\n", Options{Weight: "w"}, `weight "0" is not a positive number`},
{"a key a selector cannot spell", "k\nx\ny|z\n", Options{Key: "k"}, `contains "|"`},
{"an option naming no column", "k\nx\ny\n", Options{Key: "nope"}, `key names no column "nope"`},
@@ -48,6 +47,16 @@ func TestParseRefuses(t *testing.T) {
}
}
func TestParseAccepts(t *testing.T) {
if tb := parse(t, "t", "a\n1\n", Options{}); tb.Len() != 1 {
t.Errorf("one row: Len = %d, want 1", tb.Len())
}
tb := parse(t, "t", "k\nx\ny\n", Options{Key: "k", Name: "k"})
if r, err := tb.find("y", nil); err != nil || r != 1 {
t.Errorf("the key named as name: find(y) = %d, %v, want row 1", r, err)
}
}
func TestLinkRefusesAParentRowNoChildLinksTo(t *testing.T) {
country := parse(t, "country", "code\nSE\nNO\n", Options{Key: "code"})
city := parse(t, "city", "country\tname\nSE\tLund\nSE\tBorg\n", Options{Parent: "country"})