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