[vala/staging] tests: Add some "girparser" tests to increase coverage



commit 2189d6e6e7b0f6778bb99c4d3aca381a40866c10
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Feb 8 22:06:49 2018 +0100

    tests: Add some "girparser" tests to increase coverage

 tests/Makefile.am                                  |    5 +
 tests/gir/bug792998.test                           |   59 ++++++++
 tests/gir/class.test                               |  146 ++++++++++++++++++++
 .../delegate-closure-destroy-index-conflict.test   |   25 ++++
 tests/gir/parameter-nullable-out-simple-type.test  |   19 +++
 tests/gir/property-non-readable.test               |   20 +++
 6 files changed, 274 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 37e8821..7b9d57c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -368,8 +368,13 @@ TESTS = \
        gir/bug667751.test \
        gir/bug742012.test \
        gir/bug788775.test \
+       gir/bug792998.test \
        gir/array-fixed-length.test \
+       gir/class.test \
        gir/delegate-alias-without-target.test \
+       gir/delegate-closure-destroy-index-conflict.test \
+       gir/parameter-nullable-out-simple-type.test \
+       gir/property-non-readable.test \
        annotations/deprecated.vala \
        annotations/description.vala \
        annotations/noaccessormethod.test \
diff --git a/tests/gir/bug792998.test b/tests/gir/bug792998.test
new file mode 100644
index 0000000..ca4b18a
--- /dev/null
+++ b/tests/gir/bug792998.test
@@ -0,0 +1,59 @@
+GIR
+
+Input:
+
+<class name="Foo" c:type="TestFoo" glib:type-name="TestFoo" glib:get-type="test_foo_get_type" 
glib:type-struct="FooClass" parent="GObject.Object">
+  <method name="get_prop1" c:identifier="test_foo_get_prop1" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="gint" c:type="gint"/>
+    </return-value>
+  </method>
+  <method name="set_prop2" c:identifier="test_foo_set_prop2" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="gboolean" c:type="gboolean"/>
+    </return-value>
+    <parameters>
+      <parameter name="i" transfer-ownership="none">
+        <type name="gint" c:type="gint"/>
+      </parameter>
+    </parameters>
+  </method>
+  <property name="prop1" writable="1">
+    <type name="gint" c:type="gint"/>
+  </property>
+  <method name="set_prop1" c:identifier="test_foo_set_prop1">
+    <return-value transfer-ownership="none">
+      <type name="none"/>
+    </return-value>
+    <parameters>
+      <parameter name="value" transfer-ownership="none">
+        <type name="gint" c:type="gint"/>
+      </parameter>
+    </parameters>
+  </method>
+  <property name="prop2" writable="1">
+    <type name="gint" c:type="gint"/>
+  </property>
+  <method name="get_prop2" c:identifier="test_foo_get_prop2">
+    <return-value transfer-ownership="none">
+      <type name="gint" c:type="gint"/>
+    </return-value>
+  </method>
+</class>
+<record name="FooClass" c:type="TestFooClass" glib:is-gtype-struct-for="Foo"/>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object {
+       [CCode (has_construct_function = false)]
+       protected Foo ();
+       public int get_prop1 () throws GLib.Error;
+       public int get_prop2 ();
+       public void set_prop1 (int value);
+       public bool set_prop2 (int i) throws GLib.Error;
+       [NoAccessorMethod]
+       public int prop1 { get; set; }
+       [NoAccessorMethod]
+       public int prop2 { get; set; }
+}
diff --git a/tests/gir/class.test b/tests/gir/class.test
new file mode 100644
index 0000000..578c0b8
--- /dev/null
+++ b/tests/gir/class.test
@@ -0,0 +1,146 @@
+GIR
+
+Input:
+
+<class name="Foo" c:type="TestFoo" glib:type-name="TestFoo" glib:get-type="test_foo_get_type" 
glib:type-struct="FooClass" parent="GObject.Object">
+  <implements name="Test.IFoo"/>
+  <method name="method_virtual" c:identifier="test_foo_method_virtual" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+  </method>
+  <virtual-method name="method_virtual" invoker="method_virtual" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+  </virtual-method>
+  <method name="method_async" c:identifier="test_foo_method_async">
+    <return-value transfer-ownership="none">
+      <type name="none"/>
+    </return-value>
+    <parameters>
+      <parameter name="input" transfer-ownership="none">
+        <type name="utf8" c:type="const gchar*"/>
+      </parameter>
+      <parameter name="_callback_" transfer-ownership="none" allow-none="1" closure="2" scope="async">
+        <type name="Gio.AsyncReadyCallback" c:type="GAsyncReadyCallback"/>
+      </parameter>
+      <parameter name="_callback__target" transfer-ownership="none" allow-none="1">
+        <type name="gpointer" c:type="void*"/>
+      </parameter>
+    </parameters>
+  </method>
+  <method name="method_finish" c:identifier="test_foo_method_finish" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+    <parameters>
+      <parameter name="_res_" transfer-ownership="none">
+        <type name="Gio.AsyncResult" c:type="GAsyncResult*"/>
+      </parameter>
+      <parameter name="output" direction="out" transfer-ownership="full">
+        <type name="utf8" c:type="gchar**"/>
+      </parameter>
+    </parameters>
+  </method>
+  <constructor name="new" c:identifier="test_foo_new">
+    <return-value transfer-ownership="full">
+      <type name="Test.Foo" c:type="TestFoo*"/>
+    </return-value>
+  </constructor>
+  <constructor name="bar" c:identifier="test_foo_new_bar">
+    <return-value transfer-ownership="full">
+      <type name="Test.Foo" c:type="TestFoo*"/>
+    </return-value>
+  </constructor>
+  <property name="prop" writable="1" construct="1">
+    <type name="utf8" c:type="gchar*"/>
+  </property>
+  <method name="get_prop" c:identifier="test_foo_get_prop">
+    <return-value transfer-ownership="full">
+      <type name="utf8" c:type="gchar*"/>
+    </return-value>
+  </method>
+  <method name="set_prop" c:identifier="test_foo_set_prop">
+    <return-value transfer-ownership="none">
+      <type name="none"/>
+    </return-value>
+    <parameters>
+      <parameter name="value" transfer-ownership="none">
+        <type name="utf8" c:type="const gchar*"/>
+      </parameter>
+    </parameters>
+  </method>
+  <glib:signal name="sig">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+    <parameters>
+      <parameter name="arg" transfer-ownership="none">
+        <type name="utf8" c:type="const gchar*"/>
+      </parameter>
+    </parameters>
+  </glib:signal>
+</class>
+<record name="FooClass" c:type="TestFooClass" glib:is-gtype-struct-for="Foo">
+  <field name="method_virtual">
+    <callback name="method_virtual" c:type="method_virtual" throws="1">
+      <return-value transfer-ownership="full">
+        <type name="none"/>
+      </return-value>
+      <parameters>
+        <parameter name="self" transfer-ownership="none">
+          <type name="Test.Foo" c:type="TestFoo*"/>
+        </parameter>
+      </parameters>
+    </callback>
+  </field>
+</record>
+<record name="FooPrivate" c:type="TestFooPrivate" disguised="1"/>
+<interface name="IFoo" c:type="TestIFoo" glib:type-name="TestIFoo" glib:get-type="test_ifoo_get_type" 
glib:type-struct="IFooIface">
+  <prerequisite name="GObject.Object"/>
+  <method name="method" c:identifier="test_ifoo_method" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+  </method>
+  <virtual-method name="method" invoker="method" throws="1">
+    <return-value transfer-ownership="full">
+      <type name="none"/>
+    </return-value>
+  </virtual-method>
+</interface>
+<record name="IFooIface" c:type="TestIFooIface" glib:is-gtype-struct-for="IFoo">
+  <field name="method">
+    <callback name="method" c:type="method" throws="1">
+      <return-value transfer-ownership="full">
+        <type name="none"/>
+      </return-value>
+      <parameters>
+        <parameter name="self" transfer-ownership="none">
+          <type name="Test.IFoo" c:type="TestIFoo*"/>
+        </parameter>
+      </parameters>
+    </callback>
+  </field>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object, Test.IFoo {
+       [CCode (has_construct_function = false)]
+       public Foo ();
+       [CCode (cname = "test_foo_new_bar", has_construct_function = false)]
+       public Foo.bar ();
+       public string get_prop ();
+       public async void method_async (string input, out string output) throws GLib.Error;
+       public virtual void method_virtual () throws GLib.Error;
+       public void set_prop (string value);
+       public string prop { owned get; set construct; }
+       public signal void sig (string arg);
+}
+[CCode (cheader_filename = "test.h", type_id = "test_ifoo_get_type ()")]
+public interface IFoo : GLib.Object {
+       public abstract void method () throws GLib.Error;
+}
diff --git a/tests/gir/delegate-closure-destroy-index-conflict.test 
b/tests/gir/delegate-closure-destroy-index-conflict.test
new file mode 100644
index 0000000..4bf57bf
--- /dev/null
+++ b/tests/gir/delegate-closure-destroy-index-conflict.test
@@ -0,0 +1,25 @@
+GIR
+
+Input:
+
+<function name="function" c:identifier="test_function">
+  <return-value transfer-ownership="none">
+    <type name="none"/>
+  </return-value>
+  <parameters>
+    <parameter name="callback" transfer-ownership="none" allow-none="1" closure="1" scope="notified" 
destroy="2">
+      <type name="GLib.Func" c:type="GFunc"/>
+    </parameter>
+    <parameter name="callback_target" transfer-ownership="none" allow-none="1" closure="0">
+      <type name="gpointer" c:type="void*"/>
+    </parameter>
+    <parameter name="callback_target_destroy_notify" transfer-ownership="none" scope="call" destroy="0">
+      <type name="GLib.DestroyNotify" c:type="GDestroyNotify"/>
+    </parameter>
+  </parameters>
+</function>
+
+Output:
+
+[CCode (cheader_filename = "test.h")]
+public static void function (owned GLib.Func? callback);
diff --git a/tests/gir/parameter-nullable-out-simple-type.test 
b/tests/gir/parameter-nullable-out-simple-type.test
new file mode 100644
index 0000000..b444368
--- /dev/null
+++ b/tests/gir/parameter-nullable-out-simple-type.test
@@ -0,0 +1,19 @@
+GIR
+
+Input:
+
+<function name="function" c:identifier="test_function">
+  <return-value transfer-ownership="none">
+    <type name="none"/>
+  </return-value>
+  <parameters>
+    <parameter name="i" direction="out" transfer-ownership="full" nullable="1">
+      <type name="gint" c:type="gint*"/>
+    </parameter>
+  </parameters>
+</function>
+
+Output:
+
+[CCode (cheader_filename = "test.h")]
+public static void function (out int i);
diff --git a/tests/gir/property-non-readable.test b/tests/gir/property-non-readable.test
new file mode 100644
index 0000000..0816a4d
--- /dev/null
+++ b/tests/gir/property-non-readable.test
@@ -0,0 +1,20 @@
+GIR
+
+Input:
+
+<class name="Foo" c:type="TestFoo" glib:type-name="TestFoo" glib:get-type="test_foo_get_type" 
glib:type-struct="FooClass" parent="GObject.Object">
+  <property name="prop" readable="0" writable="1" construct-only="1">
+    <type name="gint" c:type="gint"/>
+  </property>
+</class>
+<record name="FooClass" c:type="TestFooClass" glib:is-gtype-struct-for="Foo"/>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Foo : GLib.Object {
+       [CCode (has_construct_function = false)]
+       protected Foo ();
+       [NoAccessorMethod]
+       public int prop { construct; }
+}


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