• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2. "${srcdir=.}/init.sh"; path_prepend_ . ../src
3
4# Test of Vala support.
5
6: ${XGETTEXT=xgettext}
7
8cat <<\EOF > xg-vala-1.err.vala
9int main (string[] args) {
10  var r1 = /a
11EOF
12
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
14
15cat <<\EOF > xg-vala-1.vala
16int main (string[] args) {
17    var s1 = "Simple string, " + " no gettext needed";
18    var c1 = '\'';
19    var empty = "";
20    // This is a C++ style comment
21    var s2 = _("Extract this first string");
22    var s3 = "Prefix _(" + _("Extract this second string") + ") Postfix";
23
24    var empty_verbatim = """""";
25    if (args[0] == _("Extract this thirth string")) {
26      /* _("This is a comment and must not be extracted!") */
27    }
28
29    var s4 = _("""Extract this
30    ""\t\a
31    fourth string""");
32
33    var s5 = _("Extract this \u2464th string");
34
35    var s6 = /_("This is a regex literal and must not be extracted!")\|/i;
36
37    var i1 = 1000;
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 ())
43      return 1;
44    if (1 <= /_("Regex literal after '<='")/.get_capture_count ())
45      return 1;
46    if (1 != /_("Regex literal after '!='")/.get_capture_count ())
47      return 1;
48    if (! /_("Regex literal after '!'")/.match(s1))
49      return 1;
50    if (true && /_("Regex literal after '&&'")/.match(s1))
51      return 1;
52    if (false || /_("Regex literal after '||'")/.match(s1))
53      return 1;
54
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 ();
64
65    i1++;
66    i1--;
67    i1 = i1 / i1;
68    GLib.Timeout.add (10, () => { return false; });
69
70    var d1 = 10e-1;
71    var d2 = 10E-1;
72
73    /* This is a
74       multiline C style comment */
75    var s7 = _("Extract this //sixth string");
76
77    var s8 = _(@"This is a template string, which cannot be extracted!");
78
79    /* /= shouldn't start a regex literal */
80    var i5 = 1000;
81    i5 /= 10;
82
83    return 0;
84}
85
86class Foo : Object {
87  // @ isn't always followed by a template string.
88  public static Foo @new (void) {
89    return null;
90  }
91}
92EOF
93
94${XGETTEXT} --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err
95test $? = 0 || { cat xg-vala-1.err; Exit 1; }
96func_filter_POT_Creation_Date xg-vala-1.tmp xg-vala-1.pot
97
98cat <<\EOF > xg-vala-1.ok
99# SOME DESCRIPTIVE TITLE.
100# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
101# This file is distributed under the same license as the PACKAGE package.
102# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
103#
104#, fuzzy
105msgid ""
106msgstr ""
107"Project-Id-Version: PACKAGE VERSION\n"
108"Report-Msgid-Bugs-To: \n"
109"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
110"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
111"Language-Team: LANGUAGE <LL@li.org>\n"
112"Language: \n"
113"MIME-Version: 1.0\n"
114"Content-Type: text/plain; charset=UTF-8\n"
115"Content-Transfer-Encoding: 8bit\n"
116
117#. This is a C++ style comment
118msgid "Extract this first string"
119msgstr ""
120
121msgid "Extract this second string"
122msgstr ""
123
124msgid "Extract this thirth string"
125msgstr ""
126
127msgid ""
128"Extract this\n"
129"    \"\"\\t\\a\n"
130"    fourth string"
131msgstr ""
132
133msgid "Extract this ⑤th string"
134msgstr ""
135
136#. This is a
137#. multiline C style comment
138msgid "Extract this //sixth string"
139msgstr ""
140EOF
141
142: ${DIFF=diff}
143${DIFF} xg-vala-1.ok xg-vala-1.pot
144result=$?
145test $result = 0 || exit $result
146
147# Test --extract-all option.
148${XGETTEXT} --extract-all --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err
149test $? = 0 || { cat xg-vala-1.err; Exit 1; }
150func_filter_POT_Creation_Date xg-vala-1.tmp xg-vala-1.pot
151
152cat <<\EOF > xg-vala-1.all.ok
153# SOME DESCRIPTIVE TITLE.
154# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
155# This file is distributed under the same license as the PACKAGE package.
156# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
157#
158#, fuzzy
159msgid ""
160msgstr ""
161"Project-Id-Version: PACKAGE VERSION\n"
162"Report-Msgid-Bugs-To: \n"
163"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
164"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
165"Language-Team: LANGUAGE <LL@li.org>\n"
166"Language: \n"
167"MIME-Version: 1.0\n"
168"Content-Type: text/plain; charset=UTF-8\n"
169"Content-Transfer-Encoding: 8bit\n"
170
171msgid "Simple string,  no gettext needed"
172msgstr ""
173
174#. This is a C++ style comment
175msgid "Extract this first string"
176msgstr ""
177
178msgid "Prefix _("
179msgstr ""
180
181msgid "Extract this second string"
182msgstr ""
183
184msgid ") Postfix"
185msgstr ""
186
187msgid "Extract this thirth string"
188msgstr ""
189
190msgid ""
191"Extract this\n"
192"    \"\"\\t\\a\n"
193"    fourth string"
194msgstr ""
195
196msgid "Extract this ⑤th string"
197msgstr ""
198
199#. This is a
200#. multiline C style comment
201msgid "Extract this //sixth string"
202msgstr ""
203EOF
204
205${DIFF} xg-vala-1.all.ok xg-vala-1.pot
206result=$?
207test $result = 0 || exit $result
208