summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-perl-8
blob: b165e09f67005fd5269142be0ce6d475c98e978b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#! /bin/sh
. "${srcdir=.}/init.sh"; path_prepend_ . ../src

# The slash (/) and the question mark (?) serve a double-purpose in Perl.
# Depending on the context they can either be an operator (division
# or ternary respectively) or they are regex delimiters for pattern
# matches.  This test case checks the proper recognition.

cat <<\EOF > xg-pl-8.pl
info(__("using %s."), ($a->b() eq "auto" ? "" : ""));

print __"Question mark after string is an operator!\n";
# ?; Re-sync.

@times = sort {$a - $b} split /,\s*/, $options
    if (defined $options && $options);

print __"First slash in a an argument to a function starts a pattern match.";
# /; Re-sync.

$0 =~ /xyz/ ? 'foo' : 'bar';

print __"Question mark after a regular pattern match is an operator!";
# ?; Re-sync.

$0 =~ m{xyz} ? 'foo' : 'bar';

print __"Question mark after a nesting pattern match is an operator!";
# ?; Re-sync.

$0 =~ m|xyz| ? 'foo' : 'bar';

print __"Question mark after a non-nesting pattern match is an operator!";
# ?; Re-sync.

print __(<<EOS);
Line number for here documents is not correct.
EOS

$foo = wantarray ? 1 : 0;

print __"The function wantarray does not take arguments!";
# ?; Re-sync.

$foo = Something->method ? 1 : 0;

print __"Class method calls without parentheses do not accept arguments!";
# ?; Re-sync.

$foo = $Something->method ? 1 : 0;

print __"Instance method calls without parentheses do not accept arguments!";
# ?; Re-sync.

$foo = $Some->thing->method ? 1 : 0;

print __"Chained method calls without parentheses do not accept arguments!";
# ?; Re-sync.

print __"Synching works.";
EOF

: ${XGETTEXT=xgettext}
${XGETTEXT} --omit-header -n \
  -k__ \
  -d xg-pl-8.tmp xg-pl-8.pl || Exit 1
LC_ALL=C tr -d '\r' < xg-pl-8.tmp.po > xg-pl-8.po || Exit 1

cat <<\EOF > xg-pl-8.ok
#: xg-pl-8.pl:1
#, perl-format
msgid "using %s."
msgstr ""

#: xg-pl-8.pl:3
msgid "Question mark after string is an operator!\n"
msgstr ""

#: xg-pl-8.pl:9
msgid "First slash in a an argument to a function starts a pattern match."
msgstr ""

#: xg-pl-8.pl:14
msgid "Question mark after a regular pattern match is an operator!"
msgstr ""

#: xg-pl-8.pl:19
msgid "Question mark after a nesting pattern match is an operator!"
msgstr ""

#: xg-pl-8.pl:24
msgid "Question mark after a non-nesting pattern match is an operator!"
msgstr ""

#: xg-pl-8.pl:28
msgid "Line number for here documents is not correct.\n"
msgstr ""

#: xg-pl-8.pl:33
msgid "The function wantarray does not take arguments!"
msgstr ""

#: xg-pl-8.pl:38
msgid "Class method calls without parentheses do not accept arguments!"
msgstr ""

#: xg-pl-8.pl:43
msgid "Instance method calls without parentheses do not accept arguments!"
msgstr ""

#: xg-pl-8.pl:48
msgid "Chained method calls without parentheses do not accept arguments!"
msgstr ""

#: xg-pl-8.pl:51
msgid "Synching works."
msgstr ""
EOF

: ${DIFF=diff}
${DIFF} xg-pl-8.ok xg-pl-8.po
result=$?

exit $result