]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "fast-vapi" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 3 Jan 2021 13:53:23 +0000 (14:53 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 3 Jan 2021 13:56:43 +0000 (14:56 +0100)
Backported from 0.48

configure.ac
tests/Makefile.am
tests/fastvapi/Makefile.am [new file with mode: 0644]
tests/fastvapi/fastvapitest.vala [new file with mode: 0644]
tests/fastvapi/fastvapitest.vapi-expected [new file with mode: 0644]
tests/fastvapi/usefastvapitest.vala [new file with mode: 0644]

index 72b62515b5b9619142a64d8c8c7e665afa6fb044..de371b216ca709dbfd30b40b5634294ab65ae987 100644 (file)
@@ -165,6 +165,7 @@ AC_CONFIG_FILES([Makefile
            compiler/Makefile
            vapi/Makefile
            tests/Makefile
+           tests/fastvapi/Makefile
            tests/girwriter/Makefile
            doc/Makefile
            doc/manual/Makefile
index c7a257239497d136e32af6cddcc0a45d24706e56..2c6fee3bcadc41625c5102870bfd7b141b5a881c 100644 (file)
@@ -1,6 +1,7 @@
 NULL =
 
 SUBDIRS = \
+       fastvapi \
        girwriter \
        $(NULL)
 
diff --git a/tests/fastvapi/Makefile.am b/tests/fastvapi/Makefile.am
new file mode 100644 (file)
index 0000000..83f7146
--- /dev/null
@@ -0,0 +1,33 @@
+NULL =
+
+check-fastvapi: $(top_builddir)/compiler/valac
+       G_DEBUG=fatal-warnings $(top_builddir)/compiler/valac \
+               -C \
+               --disable-version-header \
+               --vapidir $(top_srcdir)/vapi \
+               --fast-vapi fastvapitest.vapi \
+               --basedir $(srcdir) \
+               $(srcdir)/fastvapitest.vala; \
+       tail -n +3 fastvapitest.vapi | diff -wu $(srcdir)/fastvapitest.vapi-expected - || exit 1; \
+       G_DEBUG=fatal-warnings $(top_builddir)/compiler/valac \
+               -C \
+               --disable-version-header \
+               --vapidir $(top_srcdir)/vapi \
+               --use-fast-vapi fastvapitest.vapi \
+               --basedir $(builddir) \
+               $(srcdir)/usefastvapitest.vala || exit 1; \
+       rm -f fastvapitest.vapi fastvapitest.c usefastvapitest.c
+
+check: check-fastvapi
+
+EXTRA_DIST = \
+       fastvapitest.vala \
+       fastvapitest.vapi-expected \
+       usefastvapitest.vala \
+       $(NULL)
+
+CLEANFILES = \
+       fastvapitest.c \
+       fastvapitest.vapi \
+       usefastvapitest.c \
+       $(NULL)
diff --git a/tests/fastvapi/fastvapitest.vala b/tests/fastvapi/fastvapitest.vala
new file mode 100644 (file)
index 0000000..470c434
--- /dev/null
@@ -0,0 +1,59 @@
+namespace FastVapi {
+       public const int CONSTANT = 42;
+
+       public enum EnumTest {
+               VALUE
+       }
+
+       public errordomain ErrorTest {
+               FAILED
+       }
+
+       public struct TestStruct {
+               public int field_name;
+       }
+
+       public interface InterfaceTest : Object {
+               public abstract int property { get; construct set; }
+               public abstract void method (int param);
+       }
+
+       public delegate bool DelegateTest (int param);
+
+       public class Test : Object {
+               public signal void some_signal (int param);
+
+               public int field;
+
+               public weak Test weak_field;
+
+               public string property { get; construct set; }
+
+               public weak Test weak_property { get; private set; }
+
+               public Test.sub () {
+               }
+
+               public void method () {
+               }
+       }
+
+       public struct TestSubStruct : TestStruct {
+               public static int static_field_name;
+       }
+
+       public const int CONSTANT_TWO = CONSTANT;
+
+       public enum EnumTestTwo {
+               VALUE = 3,
+               VALUE_TWO = VALUE,
+       }
+
+       public class TestFundamental {
+               private TestFundamental () {
+               }
+       }
+
+       public abstract class AbstractTest {
+       }
+}
diff --git a/tests/fastvapi/fastvapitest.vapi-expected b/tests/fastvapi/fastvapitest.vapi-expected
new file mode 100644 (file)
index 0000000..913734d
--- /dev/null
@@ -0,0 +1,42 @@
+using GLib;
+
+namespace FastVapi {
+       public class Test : Object {
+               public int field;
+               public weak Test weak_field;
+               public Test.sub ();
+               public void method ();
+               public Test ();
+               public string property { get; set construct; }
+               public weak Test weak_property { get; private set; }
+               public signal void some_signal (int param);
+       }
+       public class TestFundamental {
+       }
+       public abstract class AbstractTest {
+               protected AbstractTest ();
+       }
+       public interface InterfaceTest : Object {
+               public abstract void method (int param);
+               public abstract int property { get; set construct; }
+       }
+       public struct TestStruct {
+               public int field_name;
+       }
+       public struct TestSubStruct : TestStruct {
+               public static int static_field_name;
+       }
+       public enum EnumTest {
+               VALUE
+       }
+       public enum EnumTestTwo {
+               VALUE = 3,
+               VALUE_TWO
+       }
+       public errordomain ErrorTest {
+               FAILED
+       }
+       public delegate bool DelegateTest (int param);
+       public const int CONSTANT = 42;
+       public const int CONSTANT_TWO;
+}
diff --git a/tests/fastvapi/usefastvapitest.vala b/tests/fastvapi/usefastvapitest.vala
new file mode 100644 (file)
index 0000000..46f9dda
--- /dev/null
@@ -0,0 +1,7 @@
+void main () {
+       assert (FastVapi.CONSTANT == 42);
+       assert (FastVapi.CONSTANT_TWO == 42);
+
+       assert (FastVapi.EnumTestTwo.VALUE == 3);
+       assert (FastVapi.EnumTestTwo.VALUE_TWO == 3);
+}