Test that a choice item picks anew on each draw, counting only renders drawing it twice, and that a rows weight too close to 0 is refused

This commit is contained in:
2026-10-08 12:17:01 +02:00
committed by Lillem4n
parent 31c2f2651d
commit 68c4313b7a
2 changed files with 2 additions and 1 deletions
+1
View File
@@ -38,6 +38,7 @@ func TestParseRefuses(t *testing.T) {
{"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`},
{"every weight zero", "k\tw\nx\t0\ny\t0\n", Options{Weight: "w"}, "every weight is 0"},
{"a weight too close to 0", "k\tw\nx\t1\ny\t1e-400\n", Options{Weight: "w"}, "line 3: weight 1e-400 is too close to 0 to tell from it"},
{"a negative weight", "k\tw\nx\t1\ny\t-1\n", Options{Weight: "w"}, `weight "-1" is not a number of 0 or more`},
{"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"`},
+1 -1
View File
@@ -176,7 +176,7 @@ func TestAChoiceItemKeepsTheNamesItBinds(t *testing.T) {
t.Fatalf("render %q holds %q, want each draw of the item to read one pick twice", got, h)
}
}
apart = apart || halves[0] != halves[1]
apart = apart || halves[0] != "c" && halves[1] != "c" && halves[0] != halves[1]
}
if !apart {
t.Error("100 renders of {x}|{x} never drew two different halves, want a pick per draw of the item")