[vala/staging: 3/3] tests: Add "target-glib=auto" tests to increase coverage




commit c17e3c8694df6efb7ca4b0e4d73fc612fc1d00a4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Wed Mar 3 16:06:34 2021 +0100

    tests: Add "target-glib=auto" tests to increase coverage

 tests/Makefile.am                     |  2 ++
 tests/glib/conditional-glib-api.vala  | 49 +++++++++++++++++++++++++++++++++++
 tests/glib/tests-extra-environment.sh |  1 +
 3 files changed, 52 insertions(+)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 7af73a986..07815e81d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..fc096ac92
--- /dev/null
+++ b/tests/glib/conditional-glib-api.vala
@@ -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
index 000000000..c4663a654
--- /dev/null
+++ b/tests/glib/tests-extra-environment.sh
@@ -0,0 +1 @@
+VALAFLAGS="--target-glib=auto"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]