Blame gettext-tools/tests/xgettext-perl-4

Packit Bot 06c835
#! /bin/sh
Packit Bot 06c835
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
Packit Bot 06c835
Packit Bot 06c835
# Tests for the general string extraction facilities of the Perl backend
Packit Bot 06c835
# (with option --extract-all).
Packit Bot 06c835
                                                                                
Packit Bot 06c835
cat <<\EOPERL > xg-pl-4.pl
Packit Bot 06c835
use strict;
Packit Bot 06c835
Packit Bot 06c835
# A double quoted string.
Packit Bot 06c835
print "'Your command, please?', asked the waiter.\n";
Packit Bot 06c835
# A double quoted string with interpolations.
Packit Bot 06c835
my $polite = 'please';
Packit Bot 06c835
print "'Your recommendation, $polite?', answered the guest.\n";
Packit Bot 06c835
# A reference.
Packit Bot 06c835
my $ref1 = \$polite;
Packit Bot 06c835
my $ref2 = \$ref1;
Packit Bot 06c835
my $ref3 = \$ref2;
Packit Bot 06c835
print "Yes, $$$$ref3!\n";
Packit Bot 06c835
# The qq operator and some of the more esoteric string interpolation
Packit Bot 06c835
# features of Perl.
Packit Bot 06c835
print (qq {\uU\lp \LaNd\E \ldo\lWn, \Uoh\E, yeah\Q!!!\E\\!\n});
Packit Bot 06c835
# The q operator.
Packit Bot 06c835
print q<E-Mail: <no@spam.org>.  >;
Packit Bot 06c835
# Should not be found.
Packit Bot 06c835
{ $polite =~ qr?le? }
Packit Bot 06c835
Packit Bot 06c835
# List interpolation.
Packit Bot 06c835
print "Your Perl include path starts with '$INC[0]' and it " .
Packit Bot 06c835
      "ends with '$INC[-1]'.  $#INC directories are searched.\n";
Packit Bot 06c835
# Here documents.
Packit Bot 06c835
print <
Packit Bot 06c835
Line 1\nLine 2
Packit Bot 06c835
EOF
Packit Bot 06c835
Line 1\nStill line 1
Packit Bot 06c835
EOF
Packit Bot 06c835
# Perl code inside strings.
Packit Bot 06c835
sub hello_func { return 'Hello' };
Packit Bot 06c835
print "@{[hello_func]} world!\n";
Packit Bot 06c835
# Backticks.
Packit Bot 06c835
print `ls $0`;
Packit Bot 06c835
print qx;ls $0;;
Packit Bot 06c835
Packit Bot 06c835
if (!defined($size = -s $filename)) {
Packit Bot 06c835
  # The above s is part of the function -s, not 
Packit Bot 06c835
  # the substitution operator!    
Packit Bot 06c835
}
Packit Bot 06c835
Packit Bot 06c835
# The rest requires a Unicode aware Perl.
Packit Bot 06c835
require 5.006;
Packit Bot 06c835
print "\U\x70\LO\154\x{69}\x{004E}a \Q\lRu\LLeS\E\041\n";
Packit Bot 06c835
# FIXME: The following should actually produce 'Polina4ka' in cyrillic letters.
Packit Bot 06c835
#print "\u\x{43f}\L\x{41E}\x{43b}\x{418}\E\x{43d}" .
Packit Bot 06c835
#      "\x{430}\x{447}\x{43a}\x{430}\n";
Packit Bot 06c835
EOPERL
Packit Bot 06c835
Packit Bot 06c835
: ${XGETTEXT=xgettext}
Packit Bot 06c835
LC_MESSAGES=C LC_ALL= \
Packit Bot 06c835
${XGETTEXT} -a --omit-header --no-location -o xg-pl-4.tmp.pot xg-pl-4.pl || exit 1
Packit Bot 06c835
LC_ALL=C tr -d '\r' < xg-pl-4.tmp.pot > xg-pl-4.pot || exit 1
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > xg-pl-4.ok
Packit Bot 06c835
msgid "'Your command, please?', asked the waiter.\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "please"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "'Your recommendation, $polite?', answered the guest.\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "Yes, $$$$ref3!\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "Up and down, OH, yeah\\!\\!\\!\\!\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "E-Mail: <no@spam.org>.  "
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid ""
Packit Bot 06c835
"Your Perl include path starts with '$INC[0]' and it ends with '$INC[-1]'.  "
Packit Bot 06c835
"$#INC directories are searched.\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid ""
Packit Bot 06c835
"Line 1\n"
Packit Bot 06c835
"Line 2\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "Line 1\\nStill line 1\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "Hello"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "@{[hello_func]} world!\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "ls $0"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
Packit Bot 06c835
msgid "Polina rules!\n"
Packit Bot 06c835
msgstr ""
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${DIFF=diff}
Packit Bot 06c835
${DIFF} xg-pl-4.ok xg-pl-4.pot
Packit Bot 06c835
result=$?
Packit Bot 06c835
Packit Bot 06c835
exit $result