]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "target-glib=auto" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 3 Mar 2021 15:06:34 +0000 (16:06 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 3 Mar 2021 16:48:41 +0000 (17:48 +0100)
tests/Makefile.am
tests/glib/conditional-glib-api.vala [new file with mode: 0644]
tests/glib/tests-extra-environment.sh [new file with mode: 0644]

index 7af73a9867790d3bbe004bf0ebb0c1138786a9dd..07815e81de314f1c34899d622f8d9d292e8944a1 100644 (file)
@@ -1190,6 +1190,7 @@ TESTS = \
        genie/preparser-or-expression.gs \
        genie/struct.gs \
        genie/struct-after-class.gs \
+       glib/conditional-glib-api.vala \
        $(LINUX_TESTS) \
        $(NULL)
 
@@ -1210,6 +1211,7 @@ LINUX_TESTS += \
 endif
 
 EXTRA_DIST = \
+       glib/tests-extra-environment.sh \
        gtktemplate/tests-extra-environment.sh \
        linux/tests-extra-environment.sh \
        nullability/tests-extra-environment.sh \
diff --git a/tests/glib/conditional-glib-api.vala b/tests/glib/conditional-glib-api.vala
new file mode 100644 (file)
index 0000000..fc096ac
--- /dev/null
@@ -0,0 +1,49 @@
+// glib 2.54 g_enum_to_string / g_flags_to_string
+// glib 2.58 G_GNUC_NO_INLINE
+enum FooEnum {
+       BAR;
+}
+void use_g_enum_to_string () {
+       FooEnum.BAR.to_string ();
+}
+[Flags]
+enum FooFlag {
+       BAR;
+}
+void use_g_flags_to_string () {
+       FooFlag.BAR.to_string ();
+}
+
+// glib 2.68 g_memdup2
+struct FooMemDup2 {
+       public int i;
+}
+void use_g_memdup2 () {
+       (unowned string)[] foo = { "foo", "bar", "manam"};
+       var bar = foo;
+
+       uint8[] minim = "minim".data;
+       Variant minim_v = minim;
+       minim = (uint8[]) minim_v;
+
+       FooMemDup2? manam = { 42 };
+       Variant manam_v = manam;
+       manam = (FooMemDup2?) manam_v;
+}
+
+// glib 2.68 drop volatile
+[SingleInstance]
+class FooVolatile : Object {
+}
+class BarVolatile {
+}
+void no_use_volatile () {
+       var re = /mon(str.*o)n/i;
+}
+
+void main () {
+       use_g_enum_to_string ();
+       use_g_flags_to_string ();
+       use_g_memdup2 ();
+       no_use_volatile ();
+}
diff --git a/tests/glib/tests-extra-environment.sh b/tests/glib/tests-extra-environment.sh
new file mode 100644 (file)
index 0000000..c4663a6
--- /dev/null
@@ -0,0 +1 @@
+VALAFLAGS="--target-glib=auto"