Blame gettext-tools/tests/format-lua-1

Packit Bot 06c835
#! /bin/sh
Packit Bot 06c835
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
Packit Bot 06c835
Packit Bot 06c835
# Test recognition of Lua format strings.
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > f-lu-1.data
Packit Bot 06c835
# Valid: no argument
Packit Bot 06c835
"abc%%"
Packit Bot 06c835
# Valid: one string argument
Packit Bot 06c835
"abc%s"
Packit Bot 06c835
# Valid: one string argument
Packit Bot 06c835
"abc%q"
Packit Bot 06c835
# Valid: one character argument
Packit Bot 06c835
"abc%c"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%i"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%d"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%o"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%u"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%X"
Packit Bot 06c835
# Valid: one integer argument
Packit Bot 06c835
"abc%x"
Packit Bot 06c835
# Valid: one float argument
Packit Bot 06c835
"abc%e"
Packit Bot 06c835
# Valid: one float argument
Packit Bot 06c835
"abc%E"
Packit Bot 06c835
# Valid: one float argument
Packit Bot 06c835
"abc%f"
Packit Bot 06c835
# Valid: one float argument
Packit Bot 06c835
"abc%g"
Packit Bot 06c835
# Valid: one float argument
Packit Bot 06c835
"abc%G"
Packit Bot 06c835
# Valid: one float argument with width
Packit Bot 06c835
"abc%4f"
Packit Bot 06c835
# Valid: one float argument with precision
Packit Bot 06c835
"abc%.8f"
Packit Bot 06c835
# Valid: one float argument with width and precision
Packit Bot 06c835
"abc%12.4f"
Packit Bot 06c835
# Valid: three arguments
Packit Bot 06c835
"abc%c%d%e"
Packit Bot 06c835
# Valid: three arguments with width and/or precision
Packit Bot 06c835
"abc%4.3s%.3f%0e"
Packit Bot 06c835
# Invalid: unterminated
Packit Bot 06c835
"abc%"
Packit Bot 06c835
# Invalid: unknown format specifier
Packit Bot 06c835
"abc%T"
Packit Bot 06c835
# Invalid: unknown modifier
Packit Bot 06c835
"abc%lf"
Packit Bot 06c835
# Invalid: extra precision
Packit Bot 06c835
"abc%1.1.1f"
Packit Bot 06c835
# Invalid: unterminated
Packit Bot 06c835
"abc%3"
Packit Bot 06c835
EOF
Packit Bot 06c835
: ${XGETTEXT=xgettext}
Packit Bot 06c835
n=0
Packit Bot 06c835
while read comment; do
Packit Bot 06c835
  read string
Packit Bot 06c835
  n=`expr $n + 1`
Packit Bot 06c835
  echo "gettext.gettext(${string});" > f-lu-1-$n.in
Packit Bot 06c835
  ${XGETTEXT} -L Lua -o f-lu-1-$n.po f-lu-1-$n.in || exit 1
Packit Bot 06c835
  test -f f-lu-1-$n.po || exit 1
Packit Bot 06c835
  fail=
Packit Bot 06c835
  if echo "$comment" | grep 'Valid:' > /dev/null; then
Packit Bot 06c835
    if grep lua-format f-lu-1-$n.po > /dev/null; then
Packit Bot 06c835
      :
Packit Bot 06c835
    else
Packit Bot 06c835
      fail=yes
Packit Bot 06c835
    fi
Packit Bot 06c835
  else
Packit Bot 06c835
    if grep lua-format f-lu-1-$n.po > /dev/null; then
Packit Bot 06c835
      fail=yes
Packit Bot 06c835
    else
Packit Bot 06c835
      :
Packit Bot 06c835
    fi
Packit Bot 06c835
  fi
Packit Bot 06c835
  if test -n "$fail"; then
Packit Bot 06c835
    echo "Format string recognition error:" 1>&2
Packit Bot 06c835
    cat f-lu-1-$n.in 1>&2
Packit Bot 06c835
    echo "Got:" 1>&2
Packit Bot 06c835
    cat f-lu-1-$n.po 1>&2
Packit Bot 06c835
    exit 1
Packit Bot 06c835
  fi
Packit Bot 06c835
  rm -f f-lu-1-$n.in f-lu-1-$n.po
Packit Bot 06c835
done < f-lu-1.data
Packit Bot 06c835
Packit Bot 06c835
exit 0
Packit Bot 06c835