2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test recognition of Python brace format strings.
6 cat <<\EOF > f-pyb-1.data
9 # Invalid: escaped braces
11 # Valid: a numeric argument
13 # Valid: a named argument
15 # Invalid: an empty name
17 # Invalid: unterminated name
19 # Valid: three arguments, two with equal names
20 "abc{addr},{char},{addr}"
21 # Valid: getattr operator
23 # Invalid: getattr operator with numeric field name
25 # Valid: getitem operator
27 # Invalid: unterminated getitem operator
29 # Invalid: unterminated getitem operator
31 # Invalid: unknown character in getitem operator
33 # Valid: format specifier
35 # Valid: standard format specifier
36 "abc{value:<<-#012.34e}"
37 # Invalid: non-standard format specifier
39 # Valid: nested format specifier
41 # Invalid: too many nesting of format specifier
43 # Invalid: nested format specifier, in the middle of other format specifiers
47 : ${XGETTEXT=xgettext}
49 while read comment; do
52 cat <<EOF > f-pyb-1-$n.in
55 ${XGETTEXT} -L Python -o f-pyb-1-$n.po f-pyb-1-$n.in || exit 1
56 test -f f-pyb-1-$n.po || exit 1
58 if echo "$comment" | grep 'Valid:' > /dev/null; then
59 if grep python-brace-format f-pyb-1-$n.po > /dev/null; then
65 if grep python-brace-format f-pyb-1-$n.po > /dev/null; then
71 if test -n "$fail"; then
72 echo "Format string recognition error:" 1>&2
73 cat f-pyb-1-$n.in 1>&2
75 cat f-pyb-1-$n.po 1>&2
78 rm -f f-pyb-1-$n.in f-pyb-1-$n.po