No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-python-1
blob2e478041ecfb0b98545fe650f32028ebb9c0198f
1 #! /bin/sh
3 # Test recognition of Python format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-p-1.data"
9 cat <<\EOF > f-p-1.data
10 # Valid: no argument
11 "abc%%"
12 # Valid: one character argument
13 "abc%c"
14 # Valid: one string argument
15 "abc%s"
16 # Valid: one string argument
17 "abc%r"
18 # Valid: one integer argument
19 "abc%i"
20 # Valid: one integer argument
21 "abc%d"
22 # Valid: one integer argument
23 "abc%u"
24 # Valid: one integer argument
25 "abc%o"
26 # Valid: one integer argument
27 "abc%x"
28 # Valid: one integer argument
29 "abc%X"
30 # Valid: one floating-point argument
31 "abc%e"
32 # Valid: one floating-point argument
33 "abc%E"
34 # Valid: one floating-point argument
35 "abc%f"
36 # Valid: one floating-point argument
37 "abc%g"
38 # Valid: one floating-point argument
39 "abc%G"
40 # Valid: one argument with flags
41 "abc%0#g"
42 # Valid: one argument with width
43 "abc%2g"
44 # Valid: one argument with width
45 "abc%*g"
46 # Valid: one argument with precision
47 "abc%.4g"
48 # Valid: one argument with precision
49 "abc%.*g"
50 # Valid: one argument with width and precision
51 "abc%14.4g"
52 # Valid: one argument with width and precision
53 "abc%14.*g"
54 # Valid: one argument with width and precision
55 "abc%*.4g"
56 # Valid: one argument with width and precision
57 "abc%*.*g"
58 # Valid: one argument with size specifier
59 "abc%hi"
60 # Valid: one argument with size specifier
61 "abc%li"
62 # Valid: one argument with size specifier
63 "abc%Li"
64 # Invalid: unterminated
65 "abc%"
66 # Invalid: unknown format specifier
67 "abc%y"
68 # Invalid: flags after width
69 "abc%*0g"
70 # Invalid: twice precision
71 "abc%.4.2g"
72 # Invalid: two size specifiers
73 "abc%lli"
74 # Valid: three arguments
75 "abc%d%u%u"
76 # Valid: a named argument
77 "abc%(value)d"
78 # Valid: an empty name
79 "abc%()d"
80 # Invalid: unterminated name
81 "abc%(value"
82 # Valid: ignored named argument
83 "abc%(dummy)%"
84 # Invalid: flags before name
85 "abc%0(value)d"
86 # Valid: three arguments, two with equal names
87 "abc%(addr)4x,%(char)c,%(addr)u"
88 # Invalid: argument with conflicting types
89 "abc%(addr)4x,%(char)c,%(addr)s"
90 # Valid: no conflict
91 "abc%(addr)r,%(addr)s"
92 # Invalid: mixing of named and unnamed arguments
93 "abc%d%(addr)x"
94 # Valid: named argument with constant precision
95 "abc%(addr).9x"
96 # Invalid: mixing of named and unnamed arguments
97 "abc%(addr).*x"
98 EOF
100 : ${XGETTEXT=xgettext}
102 while read comment; do
103 read string
104 n=`expr $n + 1`
105 tmpfiles="$tmpfiles f-p-1-$n.in f-p-1-$n.po"
106 cat <<EOF > f-p-1-$n.in
107 gettext(${string});
109 ${XGETTEXT} -L Python -o f-p-1-$n.po f-p-1-$n.in || exit 1
110 test -f f-p-1-$n.po || exit 1
111 fail=
112 if echo "$comment" | grep 'Valid:' > /dev/null; then
113 if grep python-format f-p-1-$n.po > /dev/null; then
115 else
116 fail=yes
118 else
119 if grep python-format f-p-1-$n.po > /dev/null; then
120 fail=yes
121 else
125 if test -n "$fail"; then
126 echo "Format string recognition error:" 1>&2
127 cat f-p-1-$n.in 1>&2
128 echo "Got:" 1>&2
129 cat f-p-1-$n.po 1>&2
130 exit 1
132 rm -f f-p-1-$n.in f-p-1-$n.po
133 done < f-p-1.data
135 rm -fr $tmpfiles
137 exit 0