Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / format-lua-2
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Test checking of Python format strings.
5
6 cat <<\EOF > f-lu-2.data
7 # Valid: %% doesn't count
8 msgid  "abc%%def"
9 msgstr "xyz"
10 # Invalid: invalid msgstr
11 msgid  "abc%%def"
12 msgstr "xyz%"
13 # Valid: same arguments, with different widths
14 msgid  "abc%2sdef"
15 msgstr "xyz%3s"
16 # Invalid: too few arguments
17 msgid  "abc%sdef%u"
18 msgstr "xyz%s"
19 # Invalid: too many arguments
20 msgid  "abc%udef"
21 msgstr "xyz%uvw%c"
22 # Valid: type compatibility
23 msgid  "abc%i"
24 msgstr "xyz%d"
25 # Valid: type compatibility
26 msgid  "abc%i"
27 msgstr "xyz%u"
28 # Valid: type compatibility
29 msgid  "abc%i"
30 msgstr "xyz%o"
31 # Valid: type compatibility
32 msgid  "abc%i"
33 msgstr "xyz%x"
34 # Valid: type compatibility
35 msgid  "abc%i"
36 msgstr "xyz%X"
37 # Valid: type compatibility
38 msgid  "abc%e"
39 msgstr "xyz%E"
40 # Valid: type compatibility
41 msgid  "abc%e"
42 msgstr "xyz%f"
43 # Valid: type compatibility
44 msgid  "abc%e"
45 msgstr "xyz%g"
46 # Valid: type compatibility
47 msgid  "abc%e"
48 msgstr "xyz%G"
49 # Invalid: type incompatibility
50 msgid  "abc%c"
51 msgstr "xyz%s"
52 # Invalid: type incompatibility
53 msgid  "abc%c"
54 msgstr "xyz%.0s"
55 # Invalid: type incompatibility
56 msgid  "abc%c"
57 msgstr "xyz%i"
58 # Invalid: type incompatibility
59 msgid  "abc%c"
60 msgstr "xyz%e"
61 # Invalid: type incompatibility
62 msgid  "abc%s"
63 msgstr "xyz%i"
64 # Invalid: type incompatibility
65 msgid  "abc%.0s"
66 msgstr "xyz%i"
67 # Invalid: type incompatibility
68 msgid  "abc%s"
69 msgstr "xyz%e"
70 # Invalid: type incompatibility
71 msgid  "abc%.0s"
72 msgstr "xyz%e"
73 # Invalid: type incompatibility
74 msgid  "abc%i"
75 msgstr "xyz%e"
76 # Invalid: type incompatibility
77 msgid  "abc%s"
78 msgstr "xyz%q"
79 # Invalid: type incompatibility
80 msgid  "abc%q"
81 msgstr "xyz%s"
82 EOF
83
84 : ${MSGFMT=msgfmt}
85 n=0
86 while read comment; do
87   read msgid_line
88   read msgstr_line
89   n=`expr $n + 1`
90   cat <<EOF > f-lu-2-$n.po
91 #, lua-format
92 ${msgid_line}
93 ${msgstr_line}
94 EOF
95   fail=
96   if echo "$comment" | grep 'Valid:' > /dev/null; then
97     if ${MSGFMT} --check-format -o f-lu-2-$n.mo f-lu-2-$n.po; then
98       :
99     else
100       fail=yes
101     fi
102   else
103     ${MSGFMT} --check-format -o f-lu-2-$n.mo f-lu-2-$n.po 2> /dev/null
104     if test $? = 1; then
105       :
106     else
107       fail=yes
108     fi
109   fi
110   if test -n "$fail"; then
111     echo "Format string checking error:" 1>&2
112     cat f-lu-2-$n.po 1>&2
113     exit 1
114   fi
115   rm -f f-lu-2-$n.po f-lu-2-$n.mo
116 done < f-lu-2.data
117
118 exit 0