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