Test that a calc over digits(0) or a repeat of 0 is refused, that an option of the wrong kind names its JSON kind, and that the root scope is the category

This commit is contained in:
2026-10-07 23:58:22 +02:00
committed by Lillem4n
parent 924ba07c1c
commit ba2ae41ffe
6 changed files with 41 additions and 6 deletions
+11
View File
@@ -1,6 +1,7 @@
package fejkdata
import (
"fmt"
"strings"
"testing"
)
@@ -182,6 +183,16 @@ func TestAChoiceItemKeepsTheNamesItBinds(t *testing.T) {
}
}
func TestTheRootScopeIsTheCategory(t *testing.T) {
root := compiled(t, `{"format":"{x as n}{n}{y}","x":"a","y":{"format":"{z as m}{m}","z":"b","repeat":2}}`).(*template)
if k := fmt.Sprint(root.nameScope.kind()); k != "category" {
t.Errorf("root scope kind = %q, want category", k)
}
if k := fmt.Sprint(root.fields["y"].(*template).nameScope.kind()); k != "repeat" {
t.Errorf("repeat scope kind = %q, want repeat", k)
}
}
func TestNameErrors(t *testing.T) {
cases := []struct {
name string