]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add more "gir" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 4 Mar 2021 18:12:15 +0000 (19:12 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 13 Mar 2021 20:23:15 +0000 (21:23 +0100)
tests/Makefile.am
tests/gir/method-class.test [new file with mode: 0644]
tests/gir/method-nowrapper.test [new file with mode: 0644]

index 043b2a825930862bbbcedeccbcd3e65dadc439dc..44dd22759e8f93485fcf1fccc89dde95648326d2 100644 (file)
@@ -720,6 +720,8 @@ TESTS = \
        gir/gtype-struct-name.test \
        gir/instance-parameter-owned.test \
        gir/method-array-length-type.test \
+       gir/method-class.test \
+       gir/method-nowrapper.test \
        gir/parameter-array-length-type.test \
        gir/parameter-nullable-out-simple-type.test \
        gir/property-non-readable.test \
diff --git a/tests/gir/method-class.test b/tests/gir/method-class.test
new file mode 100644 (file)
index 0000000..adb7ec1
--- /dev/null
@@ -0,0 +1,41 @@
+GIR
+
+Input:
+
+<class name="Foo"
+       c:symbol-prefix="foo"
+       c:type="TestFoo"
+       parent="GLib.Object"
+       abstract="1"
+       glib:type-name="TestFoo"
+       glib:get-type="test_foo_get_type"
+       glib:type-struct="FooClass">
+  <field name="parent">
+    <type name="GLib.Object" c:type="GObject"/>
+  </field>
+</class>
+<record name="FooClass"
+        c:type="TestFooClass"
+        glib:is-gtype-struct-for="Foo">
+  <method name="bar"
+          c:identifier="test_foo_class_bar">
+    <return-value transfer-ownership="none">
+      <type name="none" c:type="void"/>
+    </return-value>
+    <parameters>
+      <instance-parameter name="klass" transfer-ownership="none">
+        <type name="FooClass" c:type="TestFooClass*"/>
+      </instance-parameter>
+    </parameters>
+  </method>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public abstract class Foo : GLib.Object {
+       [CCode (has_construct_function = false)]
+       protected Foo ();
+       [CCode (cname = "test_foo_class_bar")]
+       public class void bar ();
+}
diff --git a/tests/gir/method-nowrapper.test b/tests/gir/method-nowrapper.test
new file mode 100644 (file)
index 0000000..ed2c1de
--- /dev/null
@@ -0,0 +1,51 @@
+GIR
+
+Input:
+
+<class name="Foo"
+       c:symbol-prefix="foo"
+       c:type="TestFoo"
+       parent="GLib.Object"
+       abstract="1"
+       glib:type-name="TestFoo"
+       glib:get-type="test_foo_get_type"
+       glib:type-struct="FooClass">
+  <virtual-method name="bar">
+    <return-value transfer-ownership="none">
+      <type name="gboolean" c:type="gboolean"/>
+    </return-value>
+  </virtual-method>
+  <field name="parent">
+    <type name="GLib.Object" c:type="GObject"/>
+  </field>
+</class>
+<record name="FooClass"
+        c:type="TestFooClass"
+        glib:is-gtype-struct-for="Foo">
+  <field name="parent_class">
+    <type name="GLig.ObjectClass"
+          c:type="GObjectClass"/>
+  </field>
+  <field name="bar">
+    <callback name="bar">
+      <return-value transfer-ownership="none">
+        <type name="none" c:type="void"/>
+      </return-value>
+      <parameters>
+        <parameter name="self" transfer-ownership="none">
+          <type name="Foo" c:type="TestFoo*"/>
+        </parameter>
+      </parameters>
+    </callback>
+  </field>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public abstract class Foo : GLib.Object {
+       [CCode (has_construct_function = false)]
+       protected Foo ();
+       [NoWrapper]
+       public virtual bool bar ();
+}