Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-perl-8
1 #! /bin/sh
2
3 # The slash (/) and the question mark (?) serve a double-purpose in Perl.
4 # Depending on the context they can either be an operator (division
5 # or ternary respectively) or they are regex delimiters for pattern
6 # matches.  This test case checks the proper recognition.
7
8 tmpfiles=""
9 trap 'rm -fr $tmpfiles' 1 2 3 15
10
11 tmpfiles="$tmpfiles xg-pl-8.pl"
12 cat <<\EOF > xg-pl-8.pl
13 info(__("using %s."), ($a->b() eq "auto" ? "" : ""));
14
15 print __"Question mark after string is an operator!\n";
16 # ?; Re-sync.
17
18 @times = sort {$a - $b} split /,\s*/, $options
19     if (defined $options && $options);
20
21 print __"First slash in a an argument to a function starts a pattern match.";
22 # /; Re-sync.
23
24 $0 =~ /xyz/ ? 'foo' : 'bar';
25
26 print __"Question mark after a regular pattern match is an operator!";
27 # ?; Re-sync.
28
29 $0 =~ m{xyz} ? 'foo' : 'bar';
30
31 print __"Question mark after a nesting pattern match is an operator!";
32 # ?; Re-sync.
33
34 $0 =~ m|xyz| ? 'foo' : 'bar';
35
36 print __"Question mark after a non-nesting pattern match is an operator!";
37 # ?; Re-sync.
38
39 print __(<<EOS);
40 Line number for here documents is not correct.
41 EOS
42
43 $foo = wantarray ? 1 : 0;
44
45 print __"The function wantarray does not take arguments!";
46 # ?; Re-sync.
47
48 $foo = Something->method ? 1 : 0;
49
50 print __"Class method calls without parentheses do not accept arguments!";
51 # ?; Re-sync.
52
53 $foo = $Something->method ? 1 : 0;
54
55 print __"Instance method calls without parentheses do not accept arguments!";
56 # ?; Re-sync.
57
58 $foo = $Some->thing->method ? 1 : 0;
59
60 print __"Chained method calls without parentheses do not accept arguments!";
61 # ?; Re-sync.
62
63 print __"Synching works.";
64 EOF
65
66 tmpfiles="$tmpfiles xg-pl-8.tmp.po xg-pl-8.po"
67 : ${XGETTEXT=xgettext}
68 ${XGETTEXT} --omit-header -n \
69   -k__ \
70   -d xg-pl-8.tmp xg-pl-8.pl
71 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
72 LC_ALL=C tr -d '\r' < xg-pl-8.tmp.po > xg-pl-8.po
73 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
74
75 tmpfiles="$tmpfiles xg-pl-8.ok"
76 cat <<\EOF > xg-pl-8.ok
77 #: xg-pl-8.pl:1
78 #, perl-format
79 msgid "using %s."
80 msgstr ""
81
82 #: xg-pl-8.pl:3
83 msgid "Question mark after string is an operator!\n"
84 msgstr ""
85
86 #: xg-pl-8.pl:9
87 msgid "First slash in a an argument to a function starts a pattern match."
88 msgstr ""
89
90 #: xg-pl-8.pl:14
91 msgid "Question mark after a regular pattern match is an operator!"
92 msgstr ""
93
94 #: xg-pl-8.pl:19
95 msgid "Question mark after a nesting pattern match is an operator!"
96 msgstr ""
97
98 #: xg-pl-8.pl:24
99 msgid "Question mark after a non-nesting pattern match is an operator!"
100 msgstr ""
101
102 #: xg-pl-8.pl:28
103 msgid "Line number for here documents is not correct.\n"
104 msgstr ""
105
106 #: xg-pl-8.pl:33
107 msgid "The function wantarray does not take arguments!"
108 msgstr ""
109
110 #: xg-pl-8.pl:38
111 msgid "Class method calls without parentheses do not accept arguments!"
112 msgstr ""
113
114 #: xg-pl-8.pl:43
115 msgid "Instance method calls without parentheses do not accept arguments!"
116 msgstr ""
117
118 #: xg-pl-8.pl:48
119 msgid "Chained method calls without parentheses do not accept arguments!"
120 msgstr ""
121
122 #: xg-pl-8.pl:51
123 msgid "Synching works."
124 msgstr ""
125 EOF
126
127 : ${DIFF=diff}
128 ${DIFF} xg-pl-8.ok xg-pl-8.po
129 result=$?
130
131 rm -fr $tmpfiles
132
133 exit $result