* xgettext-c-4: Check more trigraphs.
* xgettext-c-2: Check floating point literal.
* xgettext-c-19: Check out-of-range Unicode character, "\U"
character escape, incomplete "\u" escape, and surrogates.
* xgettext-vala-1: Check unterminated regexp literal, floating
point literal, string template, "/=" operator, multi-line
comments, and backslash-escaped character inside regexp literal.
+2014-10-08 Daiki Ueno <ueno@gnu.org>
+
+ tests: Improve test coverage of C and Vala scanners
+ * xgettext-c-4: Check more trigraphs.
+ * xgettext-c-2: Check floating point literal.
+ * xgettext-c-19: Check out-of-range Unicode character, "\U"
+ character escape, incomplete "\u" escape, and surrogates.
+ * xgettext-vala-1: Check unterminated regexp literal, floating
+ point literal, string template, "/=" operator, multi-line
+ comments, and backslash-escaped character inside regexp literal.
+
2014-10-03 Daiki Ueno <ueno@gnu.org>
* lang-c++: Check if CXX is "no", not ":". See commit e854d2c7
# Test C support: mixing ANSI escapes, Unicode escapes, and bare
# multibyte characters.
+: ${XGETTEXT=xgettext}
+
+cat <<\EOF > err1.c
+/* Out of range */
+gettext ("\U00110000");
+EOF
+
+(LANGUAGE= LC_ALL=C ${XGETTEXT} --no-location --no-wrap -o - err1.c 2>&1; exit) | grep 'invalid Unicode character' || exit 1
+
cat <<\EOF > xg-c-19.in.c
/* 最初のコメント */
"最初の文字列";
gettext ("二番目の文字列");
/* 三番目のコメント */
-pgettext ("\u30B3\u30F3\u30C6\u30AF\u30B9\u30C8", "\xBB\xB0\xC8\xD6\xCC\xDC\xA4\xCE\xCA\xB8\xBB\xFA\xCE\363");
+pgettext ("\u30B3\u30F3\u30C6\u30af\u30B9\u30C8\U0001F600\ud835\udc9ea", "\xBB\xB0\xC8\xD6\xCC\xDC\xA4\xCE\xCA\xB8\xBB\xFA\xCe\363");
+
+gettext ("\"\'\?\\\a\b\f\n\r\t\v\xG\0000");
+gettext ("\u30A");
EOF
: ${ICONV=iconv}
iconv -f UTF-8 -t EUC-JP < xg-c-19.in.c > xg-c-19.c \
|| { echo "Skipping test: iconv does not work for EUC-JP"; exit 77; }
-: ${XGETTEXT=xgettext}
-${XGETTEXT} --from-code=EUC-JP --add-comments --no-location \
+${XGETTEXT} --from-code=EUC-JP --add-comments --no-location --no-wrap \
-o - xg-c-19.c | grep -v 'POT-Creation-Date' > xg-c-19.tmp.po \
- || exit 1
+ || { cp core* ..; exit 1; }
LC_ALL=C tr -d '\r' < xg-c-19.tmp.po > xg-c-19.po || exit 1
-cat <<EOF > xg-c-19.ok
+cat <<\EOF > xg-c-19.ok
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
msgstr ""
#. 三番目のコメント
-msgctxt "コンテクスト"
+msgctxt "コンテクスト😀𝒞a"
msgid "三番目の文字列"
msgstr ""
+
+msgid ""
+"\"'?\\\a\b\f\n"
+"\r\t\v\\xG"
+msgstr ""
+
+msgid "\\u30A"
+msgstr ""
EOF
: ${DIFF=diff}
_("after character")
static char *s = "";
_("after string")
+static double d = 10e-1;
+_("after double")
EOF
: ${XGETTEXT=xgettext}
msgid "after string"
msgstr ""
+
+msgid "after double"
+msgstr ""
EOF
: ${DIFF=diff}
# Test C support: --trigraphs option.
cat <<EOF > xg-c-4.in.c
-main()??<printf(gettext("Hello, " "World!" "??/n")); ??>
+main()??<printf(gettext("Hello, " "World!" "??/n"));return 0 ? a??(0??'1??) : 1??!??-a[0]??#1;????>
EOF
: ${XGETTEXT=xgettext}
# Test of Vala support.
+: ${XGETTEXT=xgettext}
+
+cat <<\EOF > xg-vala-1.err.vala
+int main (string[] args) {
+ var r1 = /a
+EOF
+
+(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
+
cat <<\EOF > xg-vala-1.vala
int main (string[] args) {
var s1 = "Simple string, " + " no gettext needed";
var s5 = _("Extract this \u2464th string");
- var s6 = /_("This is a regex literal and must not be extracted!")/i;
+ var s6 = /_("This is a regex literal and must not be extracted!")\|/i;
+ var d1 = 10e-1;
+ var d2 = 10E-1;
+
+ /* This is a
+ multiline C style comment */
var s7 = _("Extract this //sixth string");
+
+ var s8 = _(@"This is a template string, which cannot be extracted!");
+
+ /* /= shouldn't start a regex literal */
+ var i1 = 1000;
+ i1 /= 10;
+
return 0;
}
EOF
-: ${XGETTEXT=xgettext}
${XGETTEXT} --add-comments --no-location -o xg-vala-1.tmp xg-vala-1.vala 2>xg-vala-1.err
test $? = 0 || { cat xg-vala-1.err; exit 1; }
# Don't simplify this to "grep ... < xg-vala-1.tmp", otherwise OpenBSD 4.0 grep
msgid "Extract this ⑤th string"
msgstr ""
+#. This is a
+#. multiline C style comment
msgid "Extract this //sixth string"
msgstr ""
EOF
msgid "Extract this ⑤th string"
msgstr ""
+#. This is a
+#. multiline C style comment
msgid "Extract this //sixth string"
msgstr ""
EOF