Imported Upstream version 0.18.1.1
[platform/upstream/gettext.git] / gettext-tools / tests / xgettext-java-2
1 #!/bin/sh
2 #
3 # More tests for java support
4 #
5
6 tmpfiles=""
7 trap 'rm -fr $tmpfiles' 1 2 3 15
8
9 tmpfiles="$tmpfiles xg-j-2.java"
10 cat <<\EOF > xg-j-2.java
11 class TestCase {
12   public static void main (String[] args) {
13     // Test recognition of \u escapes: Böse Bübchen
14     gettext ("B\u00f6se B\u00fcbchen");
15     // Test recognition of \u escapes with different number of u
16     gettext ("Japanese: \uu65e5\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu672c\u8A9e");
17     // Test recognition of \u escapes when they form UTF-16 surrogates
18     // Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
19     gettext ("script \ud835\udc9e = ...");
20     // Test invalid surrogates.
21     gettext ("invalid surrogate \ud835 first half");
22     gettext ("invalid surrogate \udc9e second half");
23     // Don't let the line numbers be confused by \u newlines.
24     \u000a \u000d \u000d\u000a
25     gettext ("embedded\nnewline");
26     // Spaces from end of comment are removed.    \u000agettext("dummy");
27     // Various ways to write a backslash are equivalent.
28     gettext ("\u005c\u005c");
29     gettext ("\u005c\");
30     gettext ("\\u005c");
31     gettext ("\\");
32     gettext ("\134");
33     // Escape sequences in strings.
34     gettext ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ...");
35     // Octal escapes have 2 or 3 digits, depending on the initial digit.
36     gettext ("bel: \7\nnewline: \12backslash: \134\ndquote-zero: \420\n");
37     // Hex escapes are not recognized
38     gettext ("no bel: \x07\n");
39     gettext // Recognized despite comments
40        ( /* Even across multiline
41 comment! */ "this is a single " /* now comes the concatenation! */ + // after +
42          "long line");
43     // Character literals are not extracted.
44     gettext ('x');
45     // Invalid concatenations are not concatenated.
46     gettext ("fooba"+'r');
47     // Verify that the static function name has priority.
48     GettextResource.gettext("NOT extracted", "this one is extracted");
49     // Verify that a comma inside braces is hidden.
50     GettextResource.gettext(
51         new Object() {
52           public int foo () {
53             return 5, 8;
54           }
55         },
56         "this is the second argument");
57   }
58 }
59 EOF
60
61 tmpfiles="$tmpfiles xg-j-2.tmp xg-j-2.pot"
62 : ${XGETTEXT=xgettext}
63 ${XGETTEXT} --from-code=ISO-8859-1 -c -o xg-j-2.tmp xg-j-2.java 2>/dev/null
64 test $? = 0 || { rm -fr $tmpfiles; exit 1; }
65 # Don't simplify this to "grep ... < xg-j-2.tmp", otherwise OpenBSD 4.0 grep
66 # only outputs "Binary file (standard input) matches".
67 cat xg-j-2.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-j-2.pot
68
69 tmpfiles="$tmpfiles xg-j-2.ok"
70 cat <<\EOF > xg-j-2.ok
71 # SOME DESCRIPTIVE TITLE.
72 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
73 # This file is distributed under the same license as the PACKAGE package.
74 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
75 #
76 #, fuzzy
77 msgid ""
78 msgstr ""
79 "Project-Id-Version: PACKAGE VERSION\n"
80 "Report-Msgid-Bugs-To: \n"
81 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
82 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
83 "Language-Team: LANGUAGE <LL@li.org>\n"
84 "Language: \n"
85 "MIME-Version: 1.0\n"
86 "Content-Type: text/plain; charset=UTF-8\n"
87 "Content-Transfer-Encoding: 8bit\n"
88
89 #. Test recognition of \u escapes: Böse Bübchen
90 #: xg-j-2.java:4
91 msgid "Böse Bübchen"
92 msgstr ""
93
94 #. Test recognition of \u escapes with different number of u
95 #: xg-j-2.java:6
96 msgid "Japanese: 日本語"
97 msgstr ""
98
99 #. Test recognition of \u escapes when they form UTF-16 surrogates
100 #. Here: U+1D49E MATHEMATICAL SCRIPT CAPITAL C
101 #: xg-j-2.java:9
102 msgid "script 𝒞 = ..."
103 msgstr ""
104
105 #. Test invalid surrogates.
106 #: xg-j-2.java:11
107 msgid "invalid surrogate � first half"
108 msgstr ""
109
110 #: xg-j-2.java:12
111 msgid "invalid surrogate � second half"
112 msgstr ""
113
114 #. Don't let the line numbers be confused by \u newlines.
115 #: xg-j-2.java:15
116 msgid ""
117 "embedded\n"
118 "newline"
119 msgstr ""
120
121 #. Spaces from end of comment are removed.
122 #: xg-j-2.java:16
123 msgid "dummy"
124 msgstr ""
125
126 #. Various ways to write a backslash are equivalent.
127 #: xg-j-2.java:18 xg-j-2.java:19 xg-j-2.java:20 xg-j-2.java:21 xg-j-2.java:22
128 msgid "\\"
129 msgstr ""
130
131 #. Escape sequences in strings.
132 #: xg-j-2.java:24
133 msgid ""
134 "t -> \t, b -> \b, n -> \n"
135 ", dquote -> \", squote -> ' ..."
136 msgstr ""
137
138 #. Octal escapes have 2 or 3 digits, depending on the initial digit.
139 #: xg-j-2.java:26
140 msgid ""
141 "bel: \a\n"
142 "newline: \n"
143 "backslash: \\\n"
144 "dquote-zero: \"0\n"
145 msgstr ""
146
147 #. Hex escapes are not recognized
148 #: xg-j-2.java:28
149 msgid "no bel: \\x07\n"
150 msgstr ""
151
152 #. Recognized despite comments
153 #. Even across multiline
154 #. comment!
155 #: xg-j-2.java:31
156 msgid "this is a single long line"
157 msgstr ""
158
159 #. Invalid concatenations are not concatenated.
160 #: xg-j-2.java:36
161 msgid "fooba"
162 msgstr ""
163
164 #. Verify that the static function name has priority.
165 #: xg-j-2.java:38
166 msgid "this one is extracted"
167 msgstr ""
168
169 #: xg-j-2.java:46
170 msgid "this is the second argument"
171 msgstr ""
172 EOF
173
174 : ${DIFF=diff}
175 ${DIFF} xg-j-2.ok xg-j-2.pot
176 result=$?
177
178 rm -fr $tmpfiles
179
180 exit $result