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.
9 trap 'rm -fr $tmpfiles' 1 2 3 15
11 tmpfiles="$tmpfiles xg-pl-8.pl"
12 cat <<\EOF > xg-pl-8.pl
13 info(__("using %s."), ($a->b() eq "auto" ? "" : ""));
15 print __"Question mark after string is an operator!\n";
18 @times = sort {$a - $b} split /,\s*/, $options
19 if (defined $options && $options);
21 print __"First slash in a an argument to a function starts a pattern match.";
24 $0 =~ /xyz/ ? 'foo' : 'bar';
26 print __"Question mark after a regular pattern match is an operator!";
29 $0 =~ m{xyz} ? 'foo' : 'bar';
31 print __"Question mark after a nesting pattern match is an operator!";
34 $0 =~ m|xyz| ? 'foo' : 'bar';
36 print __"Question mark after a non-nesting pattern match is an operator!";
40 Line number for here documents is not correct.
43 $foo = wantarray ? 1 : 0;
45 print __"The function wantarray does not take arguments!";
48 $foo = Something->method ? 1 : 0;
50 print __"Class method calls without parentheses do not accept arguments!";
53 $foo = $Something->method ? 1 : 0;
55 print __"Instance method calls without parentheses do not accept arguments!";
58 $foo = $Some->thing->method ? 1 : 0;
60 print __"Chained method calls without parentheses do not accept arguments!";
63 print __"Synching works.";
66 tmpfiles="$tmpfiles xg-pl-8.tmp.po xg-pl-8.po"
67 : ${XGETTEXT=xgettext}
68 ${XGETTEXT} --omit-header -n \
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; }
75 tmpfiles="$tmpfiles xg-pl-8.ok"
76 cat <<\EOF > xg-pl-8.ok
83 msgid "Question mark after string is an operator!\n"
87 msgid "First slash in a an argument to a function starts a pattern match."
91 msgid "Question mark after a regular pattern match is an operator!"
95 msgid "Question mark after a nesting pattern match is an operator!"
99 msgid "Question mark after a non-nesting pattern match is an operator!"
103 msgid "Line number for here documents is not correct.\n"
107 msgid "The function wantarray does not take arguments!"
111 msgid "Class method calls without parentheses do not accept arguments!"
115 msgid "Instance method calls without parentheses do not accept arguments!"
119 msgid "Chained method calls without parentheses do not accept arguments!"
123 msgid "Synching works."
128 ${DIFF} xg-pl-8.ok xg-pl-8.po