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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user