xref: /netbsd-src/external/gpl2/gettext/dist/gettext-tools/tests/xgettext-csharp-3 (revision 946379e7b37692fc43f68eb0d1c10daa0a7f3b6c)
1#!/bin/sh
2
3# More tests for C# support: string syntax
4
5tmpfiles=""
6trap 'rm -fr $tmpfiles' 1 2 3 15
7
8tmpfiles="$tmpfiles xg-cs-3.cs"
9tr '%' '\015' <<\EOF > xg-cs-3.cs
10class TestCase {
11  public static void Main (String[] args) {
12    // Test recognition of \u escapes.
13    GetString ("B\u00f6se B\u00fcbchen");
14    // \u escapes with more than one u are invalid.
15    GetString ("Japanese: \uu65e5\uuu672c\u8A9e");
16    GetString ("embedded\nnewline");
17    // Spaces from end of comment are removed.    %GetString("dummy");
18    // Two backslashes (unlike in Java, where this is just one backslash).
19    GetString ("\u005c\u005c");
20    // A 6-character string (unlike in Java, where this is just one backslash).
21    GetString ("\\u005c");
22    // A single backslash.
23    GetString ("\\");
24    // There is only one \u recognition pass.
25    GetString ("\u005cu005c");
26    // Octal escape sequences are not recognized, except for \0.
27    GetString ("\134");
28    // Escape sequences in strings.
29    GetString ("t -> \t, b -> \b, n -> \n, dquote -> \", squote -> \' ...");
30    // Hex escapes are recognized.
31    GetString ("bel: \x07\n");
32    GetString // Recognized despite comments
33       ( /* Even across multiline
34comment! */ "this is a single " /* now comes the concatenation! */ + // after +
35         "long line");
36    // Verbatim string literals are extracted.
37    GetString (@"verbatim 1");
38    // In verbatim string literals, no escape sequences are recognized.
39    GetString (@"verbatim 2 \u005c \\ \t \b \n \'");
40    // In verbatim string literals, only doubled delimiters are recognized.
41    GetString (@"verbatim 3 ""test");
42    // Normal and verbatim string literals can be concatenated.
43    GetString ("left - \"quot" + @"ation"" - right");
44    // Character literals are not extracted.
45    GetString ('x');
46    // Invalid concatenations are not concatenated.
47    GetString ("fooba"+'r');
48    // Verify that a comma inside braces is hidden.
49    MyGetString (new Object[] { "don't", "fool", "me" }, "this is the second argument");
50  }
51}
52EOF
53
54tmpfiles="$tmpfiles xg-cs-3.po"
55: ${XGETTEXT=xgettext}
56# delete POT-Creation-Date: line because the date depends on local time.
57${XGETTEXT} --output - --add-location -c -kMyGetString:2 xg-cs-3.cs 2>/dev/null \
58  | sed '/\"POT-Creation-Date:.*/d' > xg-cs-3.po
59test $? = 0 || { rm -fr $tmpfiles; exit 1; }
60
61tmpfiles="$tmpfiles xg-cs-3.ok"
62cat <<\EOF > xg-cs-3.ok
63# SOME DESCRIPTIVE TITLE.
64# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
65# This file is distributed under the same license as the PACKAGE package.
66# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
67#
68#, fuzzy
69msgid ""
70msgstr ""
71"Project-Id-Version: PACKAGE VERSION\n"
72"Report-Msgid-Bugs-To: \n"
73"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
74"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
75"Language-Team: LANGUAGE <LL@li.org>\n"
76"MIME-Version: 1.0\n"
77"Content-Type: text/plain; charset=UTF-8\n"
78"Content-Transfer-Encoding: 8bit\n"
79
80#. Test recognition of \u escapes.
81#: xg-cs-3.cs:4
82msgid "Böse Bübchen"
83msgstr ""
84
85#. \u escapes with more than one u are invalid.
86#: xg-cs-3.cs:6
87msgid "Japanese: \\uu65e5\\uuu672c語"
88msgstr ""
89
90#: xg-cs-3.cs:7
91msgid ""
92"embedded\n"
93"newline"
94msgstr ""
95
96#. Spaces from end of comment are removed.
97#: xg-cs-3.cs:8
98msgid "dummy"
99msgstr ""
100
101#. Two backslashes (unlike in Java, where this is just one backslash).
102#: xg-cs-3.cs:10
103msgid "\\\\"
104msgstr ""
105
106#. A 6-character string (unlike in Java, where this is just one backslash).
107#. There is only one \u recognition pass.
108#: xg-cs-3.cs:12 xg-cs-3.cs:16
109msgid "\\u005c"
110msgstr ""
111
112#. A single backslash.
113#: xg-cs-3.cs:14
114msgid "\\"
115msgstr ""
116
117#. Octal escape sequences are not recognized, except for \0.
118#: xg-cs-3.cs:18
119msgid "\\134"
120msgstr ""
121
122#. Escape sequences in strings.
123#: xg-cs-3.cs:20
124msgid ""
125"t -> \t, b -> \b, n -> \n"
126", dquote -> \", squote -> ' ..."
127msgstr ""
128
129#. Hex escapes are recognized.
130#: xg-cs-3.cs:22
131msgid "bel: \a\n"
132msgstr ""
133
134#. Recognized despite comments
135#. Even across multiline
136#. comment!
137#: xg-cs-3.cs:25
138msgid "this is a single long line"
139msgstr ""
140
141#. Verbatim string literals are extracted.
142#: xg-cs-3.cs:28
143msgid "verbatim 1"
144msgstr ""
145
146#. In verbatim string literals, no escape sequences are recognized.
147#: xg-cs-3.cs:30
148msgid "verbatim 2 \\u005c \\\\ \\t \\b \\n \\'"
149msgstr ""
150
151#. In verbatim string literals, only doubled delimiters are recognized.
152#: xg-cs-3.cs:32
153msgid "verbatim 3 \"test"
154msgstr ""
155
156#. Normal and verbatim string literals can be concatenated.
157#: xg-cs-3.cs:34
158msgid "left - \"quotation\" - right"
159msgstr ""
160
161#. Invalid concatenations are not concatenated.
162#: xg-cs-3.cs:38
163msgid "fooba"
164msgstr ""
165
166#. Verify that a comma inside braces is hidden.
167#: xg-cs-3.cs:40
168msgid "this is the second argument"
169msgstr ""
170EOF
171
172: ${DIFF=diff}
173${DIFF} xg-cs-3.ok xg-cs-3.po
174result=$?
175
176rm -fr $tmpfiles
177
178exit $result
179