diff --git a/calc_test.go b/calc_test.go index 608bff0..1c3dcab 100644 --- a/calc_test.go +++ b/calc_test.go @@ -96,8 +96,6 @@ func TestCalcReproducible(t *testing.T) { // TestParsedCallReadsOnlyAnOperandBuiltin pins the operands a parsed call carries for a // call that is not a calc, and for one whose expression does not parse: none, either way. -// checkCalc is what reports a bad expression, so the callers that run after it -// never meet one — but they must not have to depend on that order to be safe. func TestParsedCallReadsOnlyAnOperandBuiltin(t *testing.T) { for _, format := range []string{"{luhn()}", "{calc()}", "{calc(1 +)}", "{calc(()}"} { if toks, err := parseFormat(format); err != nil || len(toks) != 1 || toks[0].names != nil { diff --git a/inline_test.go b/inline_test.go index c2876d5..c5507e7 100644 --- a/inline_test.go +++ b/inline_test.go @@ -174,25 +174,26 @@ func TestIsTemplate(t *testing.T) { } } for arg, want := range map[string]string{ - "[abc]": `starts with "["`, - "[abc].field": `starts with "["`, - "x[1]y": `"]"`, - "x[[1]]": `"["`, - "x[]": "empty", - "a]b": `holds a "]"`, - "a}b": `holds a "}"`, - `"abc`: `holds a "\""`, - `"a]b`: `holds a "\""`, // the opener the reader typed, not the bracket behind it - "{/sv_SE.person.last}": "{/sv_SE.person.last} is the path sv_SE.person.last written as a template; write sv_SE.person.last", - `"{/sv_SE.person}"`: "write sv_SE.person", - "{.person.last}": "write person.last", - "/sv_SE.person": "write sv_SE.person", - ` "{/sv_SE.person}"`: "write sv_SE.person", - `{"format":"{/sv_SE.person}"}`: "write sv_SE.person", - "//sv_SE.person": "write sv_SE.person", - "{//sv_SE.person}": "{//sv_SE.person} is the path sv_SE.person written as a template; write sv_SE.person", - "/sv_SE/person": `path "sv_SE/person" contains "/"`, - "{/-}": `path "-" is reserved`, + "[abc]": `starts with "["`, + "[abc].field": `starts with "["`, + "x[1]y": `"]"`, + "x[[1]]": `"["`, + "x[]": "empty", + "a]b": `holds a "]"`, + "a}b": `holds a "}"`, + `"abc`: `holds a "\""`, + `"a]b`: `holds a "\""`, // the opener the reader typed, not the bracket behind it + "{/sv_SE.person.last}": "{/sv_SE.person.last} is the path sv_SE.person.last written as a template; write sv_SE.person.last", + `"{/sv_SE.person}"`: "write sv_SE.person", + "{.person.last}": "write person.last", + "/sv_SE.person": "write sv_SE.person", + ` "{/sv_SE.person}"`: "write sv_SE.person", + `{"format":"{/sv_SE.person}"}`: "write sv_SE.person", + "//sv_SE.person": "write sv_SE.person", + "{//sv_SE.person}": "{//sv_SE.person} is the path sv_SE.person written as a template; write sv_SE.person", + "/sv_SE/person": `path "sv_SE/person" contains "/"`, + "{/-}": `path "-" is reserved`, + "{/misc.currency[US Dollar (Next day)]}": "write misc.currency[US Dollar (Next day)]", } { if _, err := IsTemplate(arg); err == nil || !strings.Contains(err.Error(), want) { t.Errorf("IsTemplate(%q) = %v; want it rejected naming %s", arg, err, want)