Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-perl-4
1 #! /bin/sh
2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4 # Tests for the general string extraction facilities of the Perl backend
5 # (with option --extract-all).
6                                                                                 
7 cat <<\EOPERL > xg-pl-4.pl
8 use strict;
9
10 # A double quoted string.
11 print "'Your command, please?', asked the waiter.\n";
12 # A double quoted string with interpolations.
13 my $polite = 'please';
14 print "'Your recommendation, $polite?', answered the guest.\n";
15 # A reference.
16 my $ref1 = \$polite;
17 my $ref2 = \$ref1;
18 my $ref3 = \$ref2;
19 print "Yes, $$$$ref3!\n";
20 # The qq operator and some of the more esoteric string interpolation
21 # features of Perl.
22 print (qq {\uU\lp \LaNd\E \ldo\lWn, \Uoh\E, yeah\Q!!!\E\\!\n});
23 # The q operator.
24 print q<E-Mail: <no@spam.org>.  >;
25 # Should not be found.
26 { $polite =~ qr?le? }
27
28 # List interpolation.
29 print "Your Perl include path starts with '$INC[0]' and it " .
30       "ends with '$INC[-1]'.  $#INC directories are searched.\n";
31 # Here documents.
32 print <<EOF, <<'EOF';
33 Line 1\nLine 2
34 EOF
35 Line 1\nStill line 1
36 EOF
37 # Perl code inside strings.
38 sub hello_func { return 'Hello' };
39 print "@{[hello_func]} world!\n";
40 # Backticks.
41 print `ls $0`;
42 print qx;ls $0;;
43
44 if (!defined($size = -s $filename)) {
45   # The above s is part of the function -s, not 
46   # the substitution operator!    
47 }
48
49 # The rest requires a Unicode aware Perl.
50 require 5.006;
51 print "\U\x70\LO\154\x{69}\x{004E}a \Q\lRu\LLeS\E\041\n";
52 # FIXME: The following should actually produce 'Polina4ka' in cyrillic letters.
53 #print "\u\x{43f}\L\x{41E}\x{43b}\x{418}\E\x{43d}" .
54 #      "\x{430}\x{447}\x{43a}\x{430}\n";
55 EOPERL
56
57 : ${XGETTEXT=xgettext}
58 LC_MESSAGES=C LC_ALL= \
59 ${XGETTEXT} -a --omit-header --no-location -o xg-pl-4.tmp.pot xg-pl-4.pl || exit 1
60 LC_ALL=C tr -d '\r' < xg-pl-4.tmp.pot > xg-pl-4.pot || exit 1
61
62 cat <<\EOF > xg-pl-4.ok
63 msgid "'Your command, please?', asked the waiter.\n"
64 msgstr ""
65
66 msgid "please"
67 msgstr ""
68
69 msgid "'Your recommendation, $polite?', answered the guest.\n"
70 msgstr ""
71
72 msgid "Yes, $$$$ref3!\n"
73 msgstr ""
74
75 msgid "Up and down, OH, yeah\\!\\!\\!\\!\n"
76 msgstr ""
77
78 msgid "E-Mail: <no@spam.org>.  "
79 msgstr ""
80
81 msgid ""
82 "Your Perl include path starts with '$INC[0]' and it ends with '$INC[-1]'.  "
83 "$#INC directories are searched.\n"
84 msgstr ""
85
86 msgid ""
87 "Line 1\n"
88 "Line 2\n"
89 msgstr ""
90
91 msgid "Line 1\\nStill line 1\n"
92 msgstr ""
93
94 msgid "Hello"
95 msgstr ""
96
97 msgid "@{[hello_func]} world!\n"
98 msgstr ""
99
100 msgid "ls $0"
101 msgstr ""
102
103 msgid "Polina rules!\n"
104 msgstr ""
105 EOF
106
107 : ${DIFF=diff}
108 ${DIFF} xg-pl-4.ok xg-pl-4.pot
109 result=$?
110
111 exit $result