summaryrefslogtreecommitdiffstats
path: root/gettext-tools/tests/xgettext-perl-1
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2003-11-03 21:10:58 +0000
committerBruno Haible <bruno@clisp.org>2009-06-23 12:11:11 +0200
commitd001558f4d8df1edbb2c60b6b8d764faa51902c3 (patch)
treedfe8d61cf5c94cac006ac39fae8fd8ef1f685ce6 /gettext-tools/tests/xgettext-perl-1
parentde3b6f012529bde17a04f1342353324b963d1c1a (diff)
downloadexternal_gettext-d001558f4d8df1edbb2c60b6b8d764faa51902c3.zip
external_gettext-d001558f4d8df1edbb2c60b6b8d764faa51902c3.tar.gz
external_gettext-d001558f4d8df1edbb2c60b6b8d764faa51902c3.tar.bz2
Move xgettext-26 to xgettext-perl-1.
Diffstat (limited to 'gettext-tools/tests/xgettext-perl-1')
-rwxr-xr-xgettext-tools/tests/xgettext-perl-1328
1 files changed, 328 insertions, 0 deletions
diff --git a/gettext-tools/tests/xgettext-perl-1 b/gettext-tools/tests/xgettext-perl-1
new file mode 100755
index 0000000..8491be4
--- /dev/null
+++ b/gettext-tools/tests/xgettext-perl-1
@@ -0,0 +1,328 @@
+#!/bin/sh
+
+# Test of Perl support.
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles xg-test26.pl"
+cat <<\EOF > xg-test26.pl
+use Locale::Messages qw (textdomain bindtextdomain gettext ngettext dngettext);
+
+textdomain "prog";
+bindtextdomain "prog", "./";
+
+s/foo/
+ # stress test for string extraction /xe;
+
+print _"'Your command, please?', asked the waiter.";
+
+printf ngettext ("a piece of cake", "%d pieces of cake", $n), $n;
+
+printf _"%s is replaced by %s.", "FF", "EUR";
+
+# Should be found.
+printf dngettext prog => ("one file deleted", "%d files deleted"), $n, $n;
+
+# Should not be found.
+printf dngettext ("prog"), ("one file created", "%d files created"), $n, $n;
+
+printf dngettext "prog", <<PERL, <<PERL;
+Singular
+PERL
+Plural
+PERL
+
+print <<PERL
+tied hash $__{ Bareword
+}
+tied hash $__->{"quoted string"}
+tied hash $__->{ "weird
+formatting"}
+PERL
+
+print $__ # Welcome
+ -> # to the
+ { # Republic of
+ 'Welcome to the Republic of Perl!' #
+# Perl!
+};
+
+$! ? ?$__{"pattern match"}? : s # This is no delimiter.
+{$__{substitution}}<$__-\>{"find me"}>;
+
+# No interpolation!
+m'$__{secret}';
+
+# Multiple here documents invoked from the same line.
+print gettext <<PERL; print gettext <<PERL;
+First here document.
+PERL
+Second here document.
+PERL
+
+# These are not invalid interpolations, because the dollar is backslashed.
+printf "%s\n", gettext "abc\$def";
+printf "%s\n", gettext "abc\\\$def";
+
+# These are not interpolations.
+printf "%s\n", gettext 'abc$defg';
+printf "%s\n", gettext 'abc\$defg';
+printf "%s\n", gettext 'abc\\$defg';
+printf "%s\n", gettext 'abc\\\$defg';
+
+# Two consecutive backslashes count as one inside single-quote strings.
+printf "%s\n", gettext 'ecs\tasy';
+printf "%s\n", gettext 'ecs\\tasy';
+printf "%s\n", gettext 'ecs\\\tasy';
+printf "%s\n", gettext 'ecs\\\\tasy';
+printf "%s\n", gettext 'ecs\\\\\tasy';
+printf "%s\n", gettext q(ecs\tasy);
+printf "%s\n", gettext q(ecs\\tasy);
+printf "%s\n", gettext q(ecs\\\tasy);
+printf "%s\n", gettext q(ecs\\\\tasy);
+printf "%s\n", gettext q(ecs\\\\\tasy);
+
+# Similarly, inside double-quote strings, two consecutive backslashes count
+# as one, but the last backslash of a sequence is combined with the following
+# character if possible.
+printf "%s\n", gettext "ecs\tasy";
+printf "%s\n", gettext "ecs\\tasy";
+printf "%s\n", gettext "ecs\\\tasy";
+printf "%s\n", gettext "ecs\\\\tasy";
+printf "%s\n", gettext "ecs\\\\\tasy";
+printf "%s\n", gettext qq(ecs\tasy);
+printf "%s\n", gettext qq(ecs\\tasy);
+printf "%s\n", gettext qq(ecs\\\tasy);
+printf "%s\n", gettext qq(ecs\\\\tasy);
+printf "%s\n", gettext qq(ecs\\\\\tasy);
+printf "%s\n", gettext "mari\huana";
+printf "%s\n", gettext "mari\\huana";
+printf "%s\n", gettext "mari\\\huana";
+printf "%s\n", gettext "mari\\\\huana";
+printf "%s\n", gettext "mari\\\\\huana";
+printf "%s\n", gettext qq(mari\huana);
+printf "%s\n", gettext qq(mari\\huana);
+printf "%s\n", gettext qq(mari\\\huana);
+printf "%s\n", gettext qq(mari\\\\huana);
+printf "%s\n", gettext qq(mari\\\\\huana);
+
+# Recognition of format strings.
+gettext "This is {only} a brace formatstring.";
+gettext "This is %s {mixed}.";
+gettext "This is only %c.";
+gettext "This is nothing at all.";
+gettext "And this is %l also no format at all.";
+
+# xgettext: no-perl-format, perl-brace-format
+gettext "The function '{func}' expects '%c' here.";
+
+# This is a contradictory case: The same string three times,
+# with different xgettext comments.
+# xgettext: perl-brace-format, no-perl-format
+gettext "Left as an %exercise to {maintainer}.";
+# xgettext: no-perl-brace-format, perl-format
+gettext "Left as an %exercise to {maintainer}.";
+# No xgettext comment this time.
+gettext "Left as an %exercise to {maintainer}.";
+
+# Dollars inside sub argument lists have no effect.
+sub testFunc($) { }
+=item TestBug1
+If you have gettext()'d foo bar test1'...
+=cut
+
+# Dollars inside sub argument lists have no effect.
+testFunc = sub ($) { }
+=item TestBug2
+If you have gettext()'d foo bar test2'...
+=cut
+
+# Dollars inside sub argument lists have no effect.
+sub testFunc($\$;*@) { }
+=item TestBug3
+If you have gettext()'d foo bar test3'...
+=cut
+
+__END__
+gettext "Discarded!";
+EOF
+
+tmpfiles="$tmpfiles xg-test26.po"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --omit-header -n \
+ -k_ --flag=_:1:pass-perl-format --flag=_:1:pass-perl-brace-format \
+ -k%__ --flag=%__:1:pass-perl-format --flag=%__:1:pass-perl-brace-format \
+ -k\$__ --flag=\$__:1:pass-perl-format --flag=\$__:1:pass-perl-brace-format \
+ xg-test26.pl -d xg-test26
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-test26.ok"
+cat <<\EOF > xg-test26.ok
+#: xg-test26.pl:9
+msgid "'Your command, please?', asked the waiter."
+msgstr ""
+
+#: xg-test26.pl:11
+#, perl-format
+msgid "a piece of cake"
+msgid_plural "%d pieces of cake"
+msgstr[0] ""
+msgstr[1] ""
+
+#: xg-test26.pl:13
+#, perl-format
+msgid "%s is replaced by %s."
+msgstr ""
+
+#: xg-test26.pl:16
+#, perl-format
+msgid "one file deleted"
+msgid_plural "%d files deleted"
+msgstr[0] ""
+msgstr[1] ""
+
+#: xg-test26.pl:22
+#, perl-format
+msgid "Singular\n"
+msgid_plural "Plural\n"
+msgstr[0] ""
+msgstr[1] ""
+
+#: xg-test26.pl:28
+msgid "Bareword"
+msgstr ""
+
+#: xg-test26.pl:30
+msgid "quoted string"
+msgstr ""
+
+#: xg-test26.pl:31
+msgid ""
+"weird\n"
+"formatting"
+msgstr ""
+
+#: xg-test26.pl:38
+msgid "Welcome to the Republic of Perl!"
+msgstr ""
+
+#: xg-test26.pl:42
+msgid "pattern match"
+msgstr ""
+
+#: xg-test26.pl:43
+msgid "substitution"
+msgstr ""
+
+#: xg-test26.pl:43
+msgid "find me"
+msgstr ""
+
+#: xg-test26.pl:50
+msgid "First here document.\n"
+msgstr ""
+
+#: xg-test26.pl:52
+msgid "Second here document.\n"
+msgstr ""
+
+#: xg-test26.pl:56
+msgid "abc$def"
+msgstr ""
+
+#: xg-test26.pl:57
+msgid "abc\\$def"
+msgstr ""
+
+#: xg-test26.pl:60
+msgid "abc$defg"
+msgstr ""
+
+#: xg-test26.pl:61 xg-test26.pl:62
+msgid "abc\\$defg"
+msgstr ""
+
+#: xg-test26.pl:63
+msgid "abc\\\\$defg"
+msgstr ""
+
+#: xg-test26.pl:66 xg-test26.pl:67 xg-test26.pl:71 xg-test26.pl:72
+#: xg-test26.pl:81 xg-test26.pl:86
+msgid "ecs\\tasy"
+msgstr ""
+
+#: xg-test26.pl:68 xg-test26.pl:69 xg-test26.pl:73 xg-test26.pl:74
+#: xg-test26.pl:83 xg-test26.pl:88
+msgid "ecs\\\\tasy"
+msgstr ""
+
+#: xg-test26.pl:70 xg-test26.pl:75
+msgid "ecs\\\\\\tasy"
+msgstr ""
+
+#: xg-test26.pl:80 xg-test26.pl:85
+msgid "ecs\tasy"
+msgstr ""
+
+#: xg-test26.pl:82 xg-test26.pl:87
+msgid "ecs\\\tasy"
+msgstr ""
+
+#: xg-test26.pl:84 xg-test26.pl:89
+msgid "ecs\\\\\tasy"
+msgstr ""
+
+#: xg-test26.pl:90 xg-test26.pl:95
+msgid "marihuana"
+msgstr ""
+
+#: xg-test26.pl:91 xg-test26.pl:92 xg-test26.pl:96 xg-test26.pl:97
+msgid "mari\\huana"
+msgstr ""
+
+#: xg-test26.pl:93 xg-test26.pl:94 xg-test26.pl:98 xg-test26.pl:99
+msgid "mari\\\\huana"
+msgstr ""
+
+#: xg-test26.pl:102
+#, perl-brace-format
+msgid "This is {only} a brace formatstring."
+msgstr ""
+
+#: xg-test26.pl:103
+#, perl-format, perl-brace-format
+msgid "This is %s {mixed}."
+msgstr ""
+
+#: xg-test26.pl:104
+#, perl-format
+msgid "This is only %c."
+msgstr ""
+
+#: xg-test26.pl:105
+msgid "This is nothing at all."
+msgstr ""
+
+#: xg-test26.pl:106
+msgid "And this is %l also no format at all."
+msgstr ""
+
+#: xg-test26.pl:109
+#, no-perl-format, perl-brace-format
+msgid "The function '{func}' expects '%c' here."
+msgstr ""
+
+#: xg-test26.pl:114 xg-test26.pl:116 xg-test26.pl:118
+#, perl-format, no-perl-brace-format
+msgid "Left as an %exercise to {maintainer}."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-test26.ok xg-test26.po
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result