1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
#! /bin/sh
# Test recognition of Java format strings.
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15
tmpfiles="$tmpfiles f-j-1.data"
cat <<\EOF > f-j-1.data
# Valid: one argument
"abc{0}def"
# Valid: ten arguments
"abc{9}def"
# Valid: two-digit argument numbers
"abc{00}def"
# Valid: huge argument numbers
"abc{500000000}def"
# Invalid: unterminated
"abc{"
# Invalid: unterminated
"abc{0"
# Invalid: missing number
"abc{}def"
# Invalid: non-digit
"abc{number}def"
# Invalid: non-digit
"abc{-0}def"
# Valid: two arguments
"abc{1}def{0}"
# Valid: multiple uses of same argument
"abc{1}def{0}ghi{1}"
# Invalid: broken elementFormat
"abc{0,}def"
# Invalid: invalid elementFormat
"abc{1,string}def"
# Valid: elementFormat of length 1
"abc{1,number}def"
# Valid: elementFormat of length 1
"abc{1,date}def"
# Valid: elementFormat of length 1
"abc{1,time}def"
# Valid: elementFormat of length 1
"abc{1,choice}def"
# Invalid: broken elementFormat
"abc{1,number,}def"
# Valid: builtin numberStyle
"abc{1,number,currency}def"
# Valid: builtin numberStyle
"abc{1,number,percent}def"
# Valid: builtin numberStyle
"abc{1,number,integer}def"
# Valid: builtin datetimeStyle
"abc{1,date,short}def"
# Valid: builtin datetimeStyle
"abc{1,date,medium}def"
# Valid: builtin datetimeStyle
"abc{1,date,long}def"
# Valid: builtin datetimeStyle
"abc{1,date,full}def"
# Valid: builtin datetimeStyle
"abc{1,time,short}def"
# Valid: builtin datetimeStyle
"abc{1,time,medium}def"
# Valid: builtin datetimeStyle
"abc{1,time,long}def"
# Valid: builtin datetimeStyle
"abc{1,time,full}def"
# Valid: dateFormatPattern
"abc{1,date,foobar}"
# Valid: dateFormatPattern
"abc{1,time,foobar}"
# Valid: dateFormatPattern with comma
"abc{1,date,foo,bar}"
# Valid: numberFormatPattern
"abc{1,number,###,##0}def"
# Invalid: numberFormatPattern
"abc{1,number,foobar}"
# Valid: empty choiceFormatPattern
"abc{1,choice,}def"
# Valid: choiceFormatPattern
"abc{1,choice,0#zero|1#one|2#many}def"
# Invalid: empty clause in choiceFormatPattern
"abc{1,choice,|0#zero|1#one|2#many}def"
# Valid: empty clause at end of choiceFormatPattern
"abc{1,choice,0#zero|1#one|2#many|}def"
# Invalid: short clause in choiceFormatPattern
"abc{1,choice,-1|0#zero|1#one|2#many}def"
# Valid: short clause at end of choiceFormatPattern
"abc{1,choice,0#zero|1#one|2#many|3}def"
# Valid: choiceFormatPattern with different argument
"abc{1,choice,1#one|2#{0,date}}def"
# Valid: choiceFormatPattern with same argument
"abc{1,choice,1#one|2#{1}}def"
# Valid: choiceFormatPattern with same argument
"abc{1,choice,1#one|2#{1,number}}def"
# Invalid: choiceFormatPattern with same argument, type conflict
"abc{1,choice,1#one|2#{1,date}}def"
# Invalid: missing opening brace
"abc1}def{0}"
# Valid: quoted brace
"abc1'}'def{0}"
# Invalid: quoted brace
"abc{1'}'def"
# Valid: unterminated quote
"abc{0}1'}"
# Valid: quoted brace, '' counts as a single quote
"abc''1'}'def{0}"
# Invalid: '' counts as a single quote
"abc{1''}def"
# Valid: quote inside elementFormat is hidden
"abc{1,date,x'y}def"
# Valid: numberFormatPattern with quote
"abc{1,number,#0';'}def"
# Invalid: numberFormatPattern with wrong number syntax
"abc{1,number,#0;}def"
# Valid: numberFormatPattern with quote
"abc{1,number,0.##'E}def"
# Valid: numberFormatPattern without quote
"abc{1,number,0.##E}def"
EOF
: ${XGETTEXT=xgettext}
n=0
while read comment; do
read string
n=`expr $n + 1`
tmpfiles="$tmpfiles f-j-1-$n.in f-j-1-$n.po"
cat <<EOF > f-j-1-$n.in
gettext(${string});
EOF
${XGETTEXT} -L Java -o f-j-1-$n.po f-j-1-$n.in || exit 1
test -f f-j-1-$n.po || exit 1
fail=
if echo "$comment" | grep 'Valid:' > /dev/null; then
if grep java-format f-j-1-$n.po > /dev/null; then
:
else
fail=yes
fi
else
if grep java-format f-j-1-$n.po > /dev/null; then
fail=yes
else
:
fi
fi
if test -n "$fail"; then
echo "Format string recognition error:" 1>&2
cat f-j-1-$n.in 1>&2
echo "Got:" 1>&2
cat f-j-1-$n.po 1>&2
exit 1
fi
rm -f f-j-1-$n.in f-j-1-$n.po
done < f-j-1.data
rm -fr $tmpfiles
exit 0
|