Imported Upstream version 0.19.7
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-perl-8
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
9 cat <<\EOF > xg-pl-8.pl
10 info(__("using %s."), ($a->b() eq "auto" ? "" : ""));
11
12 print __"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
18 print __"First slash in a an argument to a function starts a pattern match.";
19 # /; Re-sync.
20
21 $0 =~ /xyz/ ? 'foo' : 'bar';
22
23 print __"Question mark after a regular pattern match is an operator!";
24 # ?; Re-sync.
25
26 $0 =~ m{xyz} ? 'foo' : 'bar';
27
28 print __"Question mark after a nesting pattern match is an operator!";
29 # ?; Re-sync.
30
31 $0 =~ m|xyz| ? 'foo' : 'bar';
32
33 print __"Question mark after a non-nesting pattern match is an operator!";
34 # ?; Re-sync.
35
36 print __(<<EOS);
37 Line number for here documents is not correct.
38 EOS
39
40 $foo = wantarray ? 1 : 0;
41
42 print __"The function wantarray does not take arguments!";
43 # ?; Re-sync.
44
45 $foo = Something->method ? 1 : 0;
46
47 print __"Class method calls without parentheses do not accept arguments!";
48 # ?; Re-sync.
49
50 $foo = $Something->method ? 1 : 0;
51
52 print __"Instance method calls without parentheses do not accept arguments!";
53 # ?; Re-sync.
54
55 $foo = $Some->thing->method ? 1 : 0;
56
57 print __"Chained method calls without parentheses do not accept arguments!";
58 # ?; Re-sync.
59
60 print __"Synching works.";
61 EOF
62
63 : ${XGETTEXT=xgettext}
64 ${XGETTEXT} --omit-header -n \
65   -k__ \
66   -d xg-pl-8.tmp xg-pl-8.pl || exit 1
67 LC_ALL=C tr -d '\r' < xg-pl-8.tmp.po > xg-pl-8.po || exit 1
68
69 cat <<\EOF > xg-pl-8.ok
70 #: xg-pl-8.pl:1
71 #, perl-format
72 msgid "using %s."
73 msgstr ""
74
75 #: xg-pl-8.pl:3
76 msgid "Question mark after string is an operator!\n"
77 msgstr ""
78
79 #: xg-pl-8.pl:9
80 msgid "First slash in a an argument to a function starts a pattern match."
81 msgstr ""
82
83 #: xg-pl-8.pl:14
84 msgid "Question mark after a regular pattern match is an operator!"
85 msgstr ""
86
87 #: xg-pl-8.pl:19
88 msgid "Question mark after a nesting pattern match is an operator!"
89 msgstr ""
90
91 #: xg-pl-8.pl:24
92 msgid "Question mark after a non-nesting pattern match is an operator!"
93 msgstr ""
94
95 #: xg-pl-8.pl:28
96 msgid "Line number for here documents is not correct.\n"
97 msgstr ""
98
99 #: xg-pl-8.pl:33
100 msgid "The function wantarray does not take arguments!"
101 msgstr ""
102
103 #: xg-pl-8.pl:38
104 msgid "Class method calls without parentheses do not accept arguments!"
105 msgstr ""
106
107 #: xg-pl-8.pl:43
108 msgid "Instance method calls without parentheses do not accept arguments!"
109 msgstr ""
110
111 #: xg-pl-8.pl:48
112 msgid "Chained method calls without parentheses do not accept arguments!"
113 msgstr ""
114
115 #: xg-pl-8.pl:51
116 msgid "Synching works."
117 msgstr ""
118 EOF
119
120 : ${DIFF=diff}
121 ${DIFF} xg-pl-8.ok xg-pl-8.po
122 result=$?
123
124 exit $result