2 . "${srcdir=.}/init.sh"; path_prepend_ . ../src
4 # Test of Vala support.
8 cat <<\EOF > xg-vala-1.err.vala
9 int main (string[] args) {
13 (LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location -o - xg-vala-1.err.vala 2>&1; exit) | grep 'regular expression literal terminated too early' || exit 1
15 cat <<\EOF > xg-vala-1.vala
16 int main (string[] args) {
17 var s1 = "Simple string, " + " no gettext needed";
20 // This is a C++ style comment
21 var s2 = _("Extract this first string");
22 var s3 = "Prefix _(" + _("Extract this second string") + ") Postfix";
24 var empty_verbatim = """""";
25 if (args[0] == _("Extract this thirth string")) {
26 /* _("This is a comment and must not be extracted!") */
29 var s4 = _("""Extract this
33 var s5 = _("Extract this \u2464th string");
35 var s6 = /_("This is a regex literal and must not be extracted!")\|/i;
38 i1 = 1 + /_("Regex literal after '+'")/.get_capture_count ();
39 i1 = 1 - /_("Regex literal after '-'")/.get_capture_count ();
40 i1 = 1 & /_("Regex literal after '-'")/.get_capture_count ();
41 i1 = 1 ^ /_("Regex literal after '^'")/.get_capture_count ();
42 if (1 < /_("Regex literal after '<'")/.get_capture_count ())
44 if (1 <= /_("Regex literal after '<='")/.get_capture_count ())
46 if (1 != /_("Regex literal after '!='")/.get_capture_count ())
48 if (! /_("Regex literal after '!'")/.match(s1))
50 if (true && /_("Regex literal after '&&'")/.match(s1))
52 if (false || /_("Regex literal after '||'")/.match(s1))
55 var r1 = true ? /_("Regex literal after '?'")/ :
56 /_("Regex literal after ':'")/;
57 var r2 = true ?? /_("Regex literal after '??'")/;
58 i1 += 1 << /_("Regex literal after '+='")/.get_capture_count ();
59 i1 *= /_("Regex literal after '*='")/.get_capture_count ();
60 i1 /= /_("Regex literal after '/='")/.get_capture_count ();
61 i1 %= /_("Regex literal after '%='")/.get_capture_count ();
62 i1 <<= /_("Regex literal after '<<='")/.get_capture_count ();
63 i1 |= /_("Regex literal after '|='")/.get_capture_count ();
68 GLib.Timeout.add (10, () => { return false; });
74 multiline C style comment */
75 var s7 = _("Extract this //sixth string");
77 var s8 = _(@"This is a template string, which cannot be extracted!");
79 /* /= shouldn't start a regex literal */
87 // @ isn't always followed by a template string.
88 public static Foo @new (void) {
94 ${XGETTEXT} --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err
95 test $? = 0 || { cat xg-vala-1.err; exit 1; }
96 # Don't simplify this to "grep ... < xg-vala-1.tmp", otherwise OpenBSD 4.0 grep
97 # only outputs "Binary file (standard input) matches".
98 cat xg-vala-1.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-vala-1.pot
100 cat <<\EOF > xg-vala-1.ok
101 # SOME DESCRIPTIVE TITLE.
102 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
103 # This file is distributed under the same license as the PACKAGE package.
104 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
109 "Project-Id-Version: PACKAGE VERSION\n"
110 "Report-Msgid-Bugs-To: \n"
111 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
112 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
113 "Language-Team: LANGUAGE <LL@li.org>\n"
115 "MIME-Version: 1.0\n"
116 "Content-Type: text/plain; charset=UTF-8\n"
117 "Content-Transfer-Encoding: 8bit\n"
119 #. This is a C++ style comment
120 msgid "Extract this first string"
123 msgid "Extract this second string"
126 msgid "Extract this thirth string"
135 msgid "Extract this ⑤th string"
139 #. multiline C style comment
140 msgid "Extract this //sixth string"
145 ${DIFF} xg-vala-1.ok xg-vala-1.pot
147 test $result = 0 || exit $result
149 # Test --extract-all option.
150 ${XGETTEXT} --extract-all --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err
151 test $? = 0 || { cat xg-vala-1.err; exit 1; }
152 # Don't simplify this to "grep ... < xg-vala-1.tmp", otherwise OpenBSD 4.0 grep
153 # only outputs "Binary file (standard input) matches".
154 cat xg-vala-1.tmp | grep -v 'POT-Creation-Date' | LC_ALL=C tr -d '\r' > xg-vala-1.pot
156 cat <<\EOF > xg-vala-1.all.ok
157 # SOME DESCRIPTIVE TITLE.
158 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
159 # This file is distributed under the same license as the PACKAGE package.
160 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
165 "Project-Id-Version: PACKAGE VERSION\n"
166 "Report-Msgid-Bugs-To: \n"
167 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
168 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
169 "Language-Team: LANGUAGE <LL@li.org>\n"
171 "MIME-Version: 1.0\n"
172 "Content-Type: text/plain; charset=UTF-8\n"
173 "Content-Transfer-Encoding: 8bit\n"
175 msgid "Simple string, no gettext needed"
178 #. This is a C++ style comment
179 msgid "Extract this first string"
185 msgid "Extract this second string"
191 msgid "Extract this thirth string"
200 msgid "Extract this ⑤th string"
204 #. multiline C style comment
205 msgid "Extract this //sixth string"
209 ${DIFF} xg-vala-1.all.ok xg-vala-1.pot
211 test $result = 0 || exit $result