| 978 | } |
| 979 | |
| 980 | func TestParse_error(t *testing.T) { |
| 981 | var tests = []struct { |
| 982 | input string |
| 983 | err string |
| 984 | }{ |
| 985 | {`foo.`, `unexpected end of expression (1:4) |
| 986 | | foo. |
| 987 | | ...^`}, |
| 988 | {`a+`, `unexpected token EOF (1:2) |
| 989 | | a+ |
| 990 | | .^`}, |
| 991 | {`a ? (1+2) c`, `unexpected token Identifier("c") (1:11) |
| 992 | | a ? (1+2) c |
| 993 | | ..........^`}, |
| 994 | {`[a b]`, `unexpected token Identifier("b") (1:4) |
| 995 | | [a b] |
| 996 | | ...^`}, |
| 997 | {`foo.bar(a b)`, `unexpected token Identifier("b") (1:11) |
| 998 | | foo.bar(a b) |
| 999 | | ..........^`}, |
| 1000 | {`{-}`, `a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Operator("-")) (1:2) |
| 1001 | | {-} |
| 1002 | | .^`}, |
| 1003 | {`foo({.bar})`, `a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Operator(".")) (1:6) |
| 1004 | | foo({.bar}) |
| 1005 | | .....^`}, |
| 1006 | {`[1, 2, 3,,]`, `unexpected token Operator(",") (1:10) |
| 1007 | | [1, 2, 3,,] |
| 1008 | | .........^`}, |
| 1009 | {`[,]`, `unexpected token Operator(",") (1:2) |
| 1010 | | [,] |
| 1011 | | .^`}, |
| 1012 | {`{,}`, `a map key must be a quoted string, a number, a identifier, or an expression enclosed in parentheses (unexpected token Operator(",")) (1:2) |
| 1013 | | {,} |
| 1014 | | .^`}, |
| 1015 | {`{foo:1, bar:2, ,}`, `unexpected token Operator(",") (1:16) |
| 1016 | | {foo:1, bar:2, ,} |
| 1017 | | ...............^`}, |
| 1018 | {`foo ?? bar || baz`, `Operator (||) and coalesce expressions (??) cannot be mixed. Wrap either by parentheses. (1:12) |
| 1019 | | foo ?? bar || baz |
| 1020 | | ...........^`}, |
| 1021 | {`0b15`, `bad number syntax: "0b15" (1:4) |
| 1022 | | 0b15 |
| 1023 | | ...^`}, |
| 1024 | {`0X10G`, `bad number syntax: "0X10G" (1:5) |
| 1025 | | 0X10G |
| 1026 | | ....^`}, |
| 1027 | {`0o1E`, `invalid float literal: strconv.ParseFloat: parsing "0o1E": invalid syntax (1:4) |
| 1028 | | 0o1E |
| 1029 | | ...^`}, |
| 1030 | {`0b1E`, `invalid float literal: strconv.ParseFloat: parsing "0b1E": invalid syntax (1:4) |
| 1031 | | 0b1E |
| 1032 | | ...^`}, |
| 1033 | {`0b1E+6`, `bad number syntax: "0b1E+6" (1:6) |
| 1034 | | 0b1E+6 |
| 1035 | | .....^`}, |
| 1036 | {`0b1E+1`, `invalid float literal: strconv.ParseFloat: parsing "0b1E+1": invalid syntax (1:6) |
| 1037 | | 0b1E+1 |