Want a lone reference whose selector holds a parenthesis refused as a template, and drop the parse test's stale order note
This commit is contained in:
@@ -96,8 +96,6 @@ func TestCalcReproducible(t *testing.T) {
|
|||||||
|
|
||||||
// TestParsedCallReadsOnlyAnOperandBuiltin pins the operands a parsed call carries for a
|
// 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.
|
// 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) {
|
func TestParsedCallReadsOnlyAnOperandBuiltin(t *testing.T) {
|
||||||
for _, format := range []string{"{luhn()}", "{calc()}", "{calc(1 +)}", "{calc(()}"} {
|
for _, format := range []string{"{luhn()}", "{calc()}", "{calc(1 +)}", "{calc(()}"} {
|
||||||
if toks, err := parseFormat(format); err != nil || len(toks) != 1 || toks[0].names != nil {
|
if toks, err := parseFormat(format); err != nil || len(toks) != 1 || toks[0].names != nil {
|
||||||
|
|||||||
+20
-19
@@ -174,25 +174,26 @@ func TestIsTemplate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for arg, want := range map[string]string{
|
for arg, want := range map[string]string{
|
||||||
"[abc]": `starts with "["`,
|
"[abc]": `starts with "["`,
|
||||||
"[abc].field": `starts with "["`,
|
"[abc].field": `starts with "["`,
|
||||||
"x[1]y": `"]"`,
|
"x[1]y": `"]"`,
|
||||||
"x[[1]]": `"["`,
|
"x[[1]]": `"["`,
|
||||||
"x[]": "empty",
|
"x[]": "empty",
|
||||||
"a]b": `holds a "]"`,
|
"a]b": `holds a "]"`,
|
||||||
"a}b": `holds a "}"`,
|
"a}b": `holds a "}"`,
|
||||||
`"abc`: `holds a "\""`,
|
`"abc`: `holds a "\""`,
|
||||||
`"a]b`: `holds a "\""`, // the opener the reader typed, not the bracket behind it
|
`"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.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",
|
`"{/sv_SE.person}"`: "write sv_SE.person",
|
||||||
"{.person.last}": "write person.last",
|
"{.person.last}": "write person.last",
|
||||||
"/sv_SE.person": "write sv_SE.person",
|
"/sv_SE.person": "write sv_SE.person",
|
||||||
` "{/sv_SE.person}"`: "write sv_SE.person",
|
` "{/sv_SE.person}"`: "write sv_SE.person",
|
||||||
`{"format":"{/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": "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}": "{//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 "/"`,
|
"/sv_SE/person": `path "sv_SE/person" contains "/"`,
|
||||||
"{/-}": `path "-" is reserved`,
|
"{/-}": `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) {
|
if _, err := IsTemplate(arg); err == nil || !strings.Contains(err.Error(), want) {
|
||||||
t.Errorf("IsTemplate(%q) = %v; want it rejected naming %s", arg, err, want)
|
t.Errorf("IsTemplate(%q) = %v; want it rejected naming %s", arg, err, want)
|
||||||
|
|||||||
Reference in New Issue
Block a user