]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
tests: Improve test coverage of Vala scanner
authorDaiki Ueno <ueno@gnu.org>
Sat, 6 Dec 2014 22:08:40 +0000 (07:08 +0900)
committerDaiki Ueno <ueno@gnu.org>
Sat, 6 Dec 2014 22:08:40 +0000 (07:08 +0900)
* xgettext-vala-1: Test regex literal right after arithmetic
assignment operators, and the case '@' is not followed by a
template string.

gettext-tools/tests/ChangeLog
gettext-tools/tests/xgettext-vala-1

index d12b51292d817c7618dd1c57a8c7ef22d2c452f1..b4fa4d053db7dc82da9e97b8c41874f84891cbcf 100644 (file)
@@ -1,3 +1,10 @@
+2014-12-07  Daiki Ueno  <ueno@gnu.org>
+
+       tests: Improve test coverage of Vala scanner
+       * xgettext-vala-1: Test regex literal right after arithmetic
+       assignment operators, and the case '@' is not followed by a
+       template string.
+
 2014-12-05  Daiki Ueno  <ueno@gnu.org>
 
        tests: Add more tests for integer overflow when reading MO file
index 9d87381f13519e31fb1322dead6df2b3ac9f9802..256b973a0835b2fa8922a73d04e68d572f7ff89b 100755 (executable)
@@ -34,6 +34,39 @@ int main (string[] args) {
 
     var s6 = /_("This is a regex literal and must not be extracted!")\|/i;
 
+    var i1 = 1000;
+    i1 = 1 + /_("Regex literal after '+'")/.get_capture_count ();
+    i1 = 1 - /_("Regex literal after '-'")/.get_capture_count ();
+    i1 = 1 & /_("Regex literal after '-'")/.get_capture_count ();
+    i1 = 1 ^ /_("Regex literal after '^'")/.get_capture_count ();
+    if (1 < /_("Regex literal after '<'")/.get_capture_count ())
+      return 1;
+    if (1 <= /_("Regex literal after '<='")/.get_capture_count ())
+      return 1;
+    if (1 != /_("Regex literal after '!='")/.get_capture_count ())
+      return 1;
+    if (! /_("Regex literal after '!'")/.match(s1))
+      return 1;
+    if (true && /_("Regex literal after '&&'")/.match(s1))
+      return 1;
+    if (false || /_("Regex literal after '||'")/.match(s1))
+      return 1;
+
+    var r1 = true ? /_("Regex literal after '?'")/ :
+        /_("Regex literal after ':'")/;
+    var r2 = true ?? /_("Regex literal after '??'")/;
+    i1 += 1 << /_("Regex literal after '+='")/.get_capture_count ();
+    i1 *= /_("Regex literal after '*='")/.get_capture_count ();
+    i1 /= /_("Regex literal after '/='")/.get_capture_count ();
+    i1 %= /_("Regex literal after '%='")/.get_capture_count ();
+    i1 <<= /_("Regex literal after '<<='")/.get_capture_count ();
+    i1 |= /_("Regex literal after '|='")/.get_capture_count ();
+
+    i1++;
+    i1--;
+    i1 = i1 / i1;
+    GLib.Timeout.add (10, () => { return false; });
+
     var d1 = 10e-1;
     var d2 = 10E-1;
 
@@ -44,13 +77,21 @@ int main (string[] args) {
     var s8 = _(@"This is a template string, which cannot be extracted!");
 
     /* /= shouldn't start a regex literal */
-    var i1 = 1000;
-    i1 /= 10;
-
+    var i5 = 1000;
+    i5 /= 10;
+    
     return 0;
 }
+
+class Foo : Object {
+  // @ isn't always followed by a template string.
+  public static Foo @new (void) {
+    return null;
+  }
+}
 EOF
 
+cp xg-vala-1.vala ..
 ${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