No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gettext / gettext-tools / tests / xgettext-perl-1
blob5afb3258762d02264c8cb95111dc9fbda27e856d
1 #!/bin/sh
3 # Test of Perl support.
5 tmpfiles=""
6 trap 'rm -fr $tmpfiles' 1 2 3 15
8 tmpfiles="$tmpfiles xg-pl-1.pl"
9 cat <<\EOF > xg-pl-1.pl
10 use Locale::Messages qw (textdomain bindtextdomain gettext ngettext dngettext);
12 textdomain "prog";
13 bindtextdomain "prog", "./";
15 s/foo/
16 # stress test for string extraction /xe;
18 print _"'Your command, please?', asked the waiter.";
20 printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n;
22 printf _"%s is replaced by %s.", "FF", "EUR";
24 # Should be found.
25 printf dngettext prog => ("one file deleted", "%d files deleted"), $n, $n;
27 # Should not be found.
28 printf dngettext ("prog"), ("one file created", "%d files created"), $n, $n;
30 printf dngettext "prog", <<PERL, <<PERL;
31 Singular
32 PERL
33 Plural
34 PERL
36 print <<PERL
37 tied hash $__{ Bareword
39 tied hash $__->{"quoted string"}
40 tied hash $__->{ "weird
41 formatting"}
42 PERL
44 print $__ # Welcome
45 -> # to the
46 { # Republic of
47 'Welcome to the Republic of Perl!' #
48 # Perl!
49 };
51 $! ? ?$__{"pattern match"}? : s # This is no delimiter.
52 {$__{substitution}}<$__-\>{"find me"}>;
54 # No interpolation!
55 m'$__{secret}';
57 # Multiple here documents invoked from the same line.
58 print gettext <<PERL; print gettext <<PERL;
59 First here document.
60 PERL
61 Second here document.
62 PERL
64 # These are not invalid interpolations, because the dollar is backslashed.
65 printf "%s\n", gettext "abc\$def";
66 printf "%s\n", gettext "abc\\\$def";
68 # These are not interpolations.
69 printf "%s\n", gettext 'abc$defg';
70 printf "%s\n", gettext 'abc\$defg';
71 printf "%s\n", gettext 'abc\\$defg';
72 printf "%s\n", gettext 'abc\\\$defg';
74 # Two consecutive backslashes count as one inside single-quote strings.
75 printf "%s\n", gettext 'ecs\tasy';
76 printf "%s\n", gettext 'ecs\\tasy';
77 printf "%s\n", gettext 'ecs\\\tasy';
78 printf "%s\n", gettext 'ecs\\\\tasy';
79 printf "%s\n", gettext 'ecs\\\\\tasy';
80 printf "%s\n", gettext q(ecs\tasy);
81 printf "%s\n", gettext q(ecs\\tasy);
82 printf "%s\n", gettext q(ecs\\\tasy);
83 printf "%s\n", gettext q(ecs\\\\tasy);
84 printf "%s\n", gettext q(ecs\\\\\tasy);
86 # Similarly, inside double-quote strings, two consecutive backslashes count
87 # as one, but the last backslash of a sequence is combined with the following
88 # character if possible.
89 printf "%s\n", gettext "ecs\tasy";
90 printf "%s\n", gettext "ecs\\tasy";
91 printf "%s\n", gettext "ecs\\\tasy";
92 printf "%s\n", gettext "ecs\\\\tasy";
93 printf "%s\n", gettext "ecs\\\\\tasy";
94 printf "%s\n", gettext qq(ecs\tasy);
95 printf "%s\n", gettext qq(ecs\\tasy);
96 printf "%s\n", gettext qq(ecs\\\tasy);
97 printf "%s\n", gettext qq(ecs\\\\tasy);
98 printf "%s\n", gettext qq(ecs\\\\\tasy);
99 printf "%s\n", gettext "mari\huana";
100 printf "%s\n", gettext "mari\\huana";
101 printf "%s\n", gettext "mari\\\huana";
102 printf "%s\n", gettext "mari\\\\huana";
103 printf "%s\n", gettext "mari\\\\\huana";
104 printf "%s\n", gettext qq(mari\huana);
105 printf "%s\n", gettext qq(mari\\huana);
106 printf "%s\n", gettext qq(mari\\\huana);
107 printf "%s\n", gettext qq(mari\\\\huana);
108 printf "%s\n", gettext qq(mari\\\\\huana);
110 # Recognition of format strings.
111 gettext "This is {only} a brace formatstring.";
112 gettext "This is %s {mixed}.";
113 gettext "This is only %c.";
114 gettext "This is nothing at all.";
115 gettext "And this is %l also no format at all.";
117 # xgettext: no-perl-format, perl-brace-format
118 gettext "The function '{func}' expects '%c' here.";
120 # This is a contradictory case: The same string three times,
121 # with different xgettext comments.
122 # xgettext: perl-brace-format, no-perl-format
123 gettext "Left as an %exercise to {maintainer}.";
124 # xgettext: no-perl-brace-format, perl-format
125 gettext "Left as an %exercise to {maintainer}.";
126 # No xgettext comment this time.
127 gettext "Left as an %exercise to {maintainer}.";
129 # Dollars inside sub argument lists have no effect.
130 sub testFunc($) { }
131 =item TestBug1
132 If you have gettext()'d foo bar test1'...
133 =cut
135 # Dollars inside sub argument lists have no effect.
136 testFunc = sub ($) { }
137 =item TestBug2
138 If you have gettext()'d foo bar test2'...
139 =cut
141 # Dollars inside sub argument lists have no effect.
142 sub testFunc($\$;*@) { }
143 =item TestBug3
144 If you have gettext()'d foo bar test3'...
145 =cut
147 __END__
148 gettext "Discarded!";
151 tmpfiles="$tmpfiles xg-pl-1.po"
152 : ${XGETTEXT=xgettext}
153 ${XGETTEXT} --omit-header -n \
154 -k_ --flag=_:1:pass-perl-format --flag=_:1:pass-perl-brace-format \
155 -k%__ --flag=%__:1:pass-perl-format --flag=%__:1:pass-perl-brace-format \
156 -k\$__ --flag=\$__:1:pass-perl-format --flag=\$__:1:pass-perl-brace-format \
157 xg-pl-1.pl -d xg-pl-1
158 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
160 tmpfiles="$tmpfiles xg-pl-1.ok"
161 cat <<\EOF > xg-pl-1.ok
162 #: xg-pl-1.pl:9
163 msgid "'Your command, please?', asked the waiter."
164 msgstr ""
166 #: xg-pl-1.pl:11
167 #, perl-format
168 msgid "a piece of cake"
169 msgid_plural "%d pieces of cake"
170 msgstr[0] ""
171 msgstr[1] ""
173 #: xg-pl-1.pl:13
174 #, perl-format
175 msgid "%s is replaced by %s."
176 msgstr ""
178 #: xg-pl-1.pl:16
179 #, perl-format
180 msgid "one file deleted"
181 msgid_plural "%d files deleted"
182 msgstr[0] ""
183 msgstr[1] ""
185 #: xg-pl-1.pl:22
186 #, perl-format
187 msgid "Singular\n"
188 msgid_plural "Plural\n"
189 msgstr[0] ""
190 msgstr[1] ""
192 #: xg-pl-1.pl:28
193 msgid "Bareword"
194 msgstr ""
196 #: xg-pl-1.pl:30
197 msgid "quoted string"
198 msgstr ""
200 #: xg-pl-1.pl:31
201 msgid ""
202 "weird\n"
203 "formatting"
204 msgstr ""
206 #: xg-pl-1.pl:38
207 msgid "Welcome to the Republic of Perl!"
208 msgstr ""
210 #: xg-pl-1.pl:42
211 msgid "pattern match"
212 msgstr ""
214 #: xg-pl-1.pl:43
215 msgid "substitution"
216 msgstr ""
218 #: xg-pl-1.pl:43
219 msgid "find me"
220 msgstr ""
222 #: xg-pl-1.pl:50
223 msgid "First here document.\n"
224 msgstr ""
226 #: xg-pl-1.pl:52
227 msgid "Second here document.\n"
228 msgstr ""
230 #: xg-pl-1.pl:56
231 msgid "abc$def"
232 msgstr ""
234 #: xg-pl-1.pl:57
235 msgid "abc\\$def"
236 msgstr ""
238 #: xg-pl-1.pl:60
239 msgid "abc$defg"
240 msgstr ""
242 #: xg-pl-1.pl:61 xg-pl-1.pl:62
243 msgid "abc\\$defg"
244 msgstr ""
246 #: xg-pl-1.pl:63
247 msgid "abc\\\\$defg"
248 msgstr ""
250 #: xg-pl-1.pl:66 xg-pl-1.pl:67 xg-pl-1.pl:71 xg-pl-1.pl:72 xg-pl-1.pl:81
251 #: xg-pl-1.pl:86
252 msgid "ecs\\tasy"
253 msgstr ""
255 #: xg-pl-1.pl:68 xg-pl-1.pl:69 xg-pl-1.pl:73 xg-pl-1.pl:74 xg-pl-1.pl:83
256 #: xg-pl-1.pl:88
257 msgid "ecs\\\\tasy"
258 msgstr ""
260 #: xg-pl-1.pl:70 xg-pl-1.pl:75
261 msgid "ecs\\\\\\tasy"
262 msgstr ""
264 #: xg-pl-1.pl:80 xg-pl-1.pl:85
265 msgid "ecs\tasy"
266 msgstr ""
268 #: xg-pl-1.pl:82 xg-pl-1.pl:87
269 msgid "ecs\\\tasy"
270 msgstr ""
272 #: xg-pl-1.pl:84 xg-pl-1.pl:89
273 msgid "ecs\\\\\tasy"
274 msgstr ""
276 #: xg-pl-1.pl:90 xg-pl-1.pl:95
277 msgid "marihuana"
278 msgstr ""
280 #: xg-pl-1.pl:91 xg-pl-1.pl:92 xg-pl-1.pl:96 xg-pl-1.pl:97
281 msgid "mari\\huana"
282 msgstr ""
284 #: xg-pl-1.pl:93 xg-pl-1.pl:94 xg-pl-1.pl:98 xg-pl-1.pl:99
285 msgid "mari\\\\huana"
286 msgstr ""
288 #: xg-pl-1.pl:102
289 #, perl-brace-format
290 msgid "This is {only} a brace formatstring."
291 msgstr ""
293 #: xg-pl-1.pl:103
294 #, perl-format, perl-brace-format
295 msgid "This is %s {mixed}."
296 msgstr ""
298 #: xg-pl-1.pl:104
299 #, perl-format
300 msgid "This is only %c."
301 msgstr ""
303 #: xg-pl-1.pl:105
304 msgid "This is nothing at all."
305 msgstr ""
307 #: xg-pl-1.pl:106
308 msgid "And this is %l also no format at all."
309 msgstr ""
311 #: xg-pl-1.pl:109
312 #, no-perl-format, perl-brace-format
313 msgid "The function '{func}' expects '%c' here."
314 msgstr ""
316 #: xg-pl-1.pl:114 xg-pl-1.pl:116 xg-pl-1.pl:118
317 #, perl-format, no-perl-brace-format
318 msgid "Left as an %exercise to {maintainer}."
319 msgstr ""
322 : ${DIFF=diff}
323 ${DIFF} xg-pl-1.ok xg-pl-1.po
324 result=$?
326 rm -fr $tmpfiles
328 exit $result