No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / format-php-1
blob9efb3a5416138280228320dd2e88f36ce1ec47ea
1 #! /bin/sh
3 # Test recognition of PHP format strings.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles f-ph-1.data"
9 cat <<\EOF > f-ph-1.data
10 # Valid: no argument
11 "abc%%"
12 # Valid: one string argument
13 "abc%s"
14 # Valid: one integer argument
15 "abc%b"
16 # Valid: one integer argument
17 "abc%d"
18 # Valid: one integer argument
19 "abc%u"
20 # Valid: one integer argument
21 "abc%o"
22 # Valid: one integer argument
23 "abc%x"
24 # Valid: one integer argument
25 "abc%X"
26 # Valid: one floating-point argument
27 "abc%e"
28 # Valid: one floating-point argument
29 "abc%f"
30 # Valid: one character argument
31 "abc%c"
32 # Valid: one argument with flags
33 "abc%-f"
34 # Valid: one argument with padding flags
35 "abc%'=f"
36 # Valid: one argument with width
37 "abc%2f"
38 # Valid: one argument with precision
39 "abc%.4f"
40 # Valid: one argument with width and precision
41 "abc%14.4f"
42 # Invalid: unterminated
43 "abc%"
44 # Invalid: unknown format specifier
45 "abc%y"
46 # Invalid: unknown format specifier
47 "abc%F"
48 # Invalid: flags after width
49 "abc%5-f"
50 # Invalid: twice precision
51 "abc%.4.2f"
52 # Valid: three arguments
53 "abc%d%x%x"
54 # Valid: a numbered argument
55 "abc%1$d"
56 # Invalid: zero
57 "abc%0$d"
58 # Valid: two-digit numbered arguments
59 "abc%11$def%10$dgh%9$dij%8$dkl%7$dmn%6$dop%5$dqr%4$dst%3$duv%2$dwx%1$dyz"
60 # Invalid: unterminated number
61 "abc%1"
62 # Invalid: flags before number
63 "abc%-1$d"
64 # Valid: three arguments, two with same number
65 "abc%1$4x,%2$c,%1$u"
66 # Invalid: argument with conflicting types
67 "abc%1$4x,%2$c,%1$s"
68 # Valid: no conflict
69 "abc%1$4x,%2$c,%1$u"
70 # Valid: mixing of numbered and unnumbered arguments
71 "abc%d%2$x"
72 # Valid: numbered argument with constant precision
73 "abc%1$.9x"
74 # Valid: missing non-final argument
75 "abc%2$x%3$s"
76 # Valid: permutation
77 "abc%2$ddef%1$d"
78 # Valid: multiple uses of same argument
79 "abc%2$xdef%1$sghi%2$x"
80 EOF
82 : ${XGETTEXT=xgettext}
83 n=0
84 while read comment; do
85 read string
86 n=`expr $n + 1`
87 tmpfiles="$tmpfiles f-ph-1-$n.in f-ph-1-$n.po"
88 echo "<?= gettext(${string}) ?>" | sed -e 's/\$/\\\$/g' > f-ph-1-$n.in
89 ${XGETTEXT} -L PHP -o f-ph-1-$n.po f-ph-1-$n.in || exit 1
90 test -f f-ph-1-$n.po || exit 1
91 fail=
92 if echo "$comment" | grep 'Valid:' > /dev/null; then
93 if grep php-format f-ph-1-$n.po > /dev/null; then
95 else
96 fail=yes
98 else
99 if grep php-format f-ph-1-$n.po > /dev/null; then
100 fail=yes
101 else
105 if test -n "$fail"; then
106 echo "Format string recognition error:" 1>&2
107 cat f-ph-1-$n.in 1>&2
108 echo "Got:" 1>&2
109 cat f-ph-1-$n.po 1>&2
110 exit 1
112 rm -f f-ph-1-$n.in f-ph-1-$n.po
113 done < f-ph-1.data
115 rm -fr $tmpfiles
117 exit 0