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