[vala/0.40] tests: Add "fast-vapi" test to increase coverage



commit b25b1eae9c05589e245bb06684f2bc396ee4f8eb
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Jan 3 14:53:23 2021 +0100

    tests: Add "fast-vapi" test to increase coverage
    
    Backported from 0.48

 configure.ac                              |  1 +
 tests/Makefile.am                         |  1 +
 tests/fastvapi/Makefile.am                | 33 +++++++++++++++++
 tests/fastvapi/fastvapitest.vala          | 59 +++++++++++++++++++++++++++++++
 tests/fastvapi/fastvapitest.vapi-expected | 42 ++++++++++++++++++++++
 tests/fastvapi/usefastvapitest.vala       |  7 ++++
 6 files changed, 143 insertions(+)
---
diff --git a/configure.ac b/configure.ac
index 72b62515b..de371b216 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c7a257239..2c6fee3bc 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 000000000..83f714663
--- /dev/null
+++ b/tests/fastvapi/Makefile.am
@@ -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
index 000000000..470c434e3
--- /dev/null
+++ b/tests/fastvapi/fastvapitest.vala
@@ -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
index 000000000..913734d0e
--- /dev/null
+++ b/tests/fastvapi/fastvapitest.vapi-expected
@@ -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
index 000000000..46f9ddaa1
--- /dev/null
+++ b/tests/fastvapi/usefastvapitest.vala
@@ -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);
+}


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