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