]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add more "girparser" tests to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Sun, 21 Feb 2021 18:34:48 +0000 (19:34 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 27 Feb 2021 19:26:43 +0000 (20:26 +0100)
tests/Makefile.am
tests/gir/alias.test [new file with mode: 0644]
tests/gir/class.test
tests/gir/union-transparent.test [new file with mode: 0644]

index 54f23ef36ba0c4cc423d8993d37c12fdd85276b1..5e4087d4e9e3a4378460cfee42da5911e71bdb8e 100644 (file)
@@ -699,6 +699,7 @@ TESTS = \
        gir/bug742012.test \
        gir/bug788775.test \
        gir/bug792998.test \
+       gir/alias.test \
        gir/array-fixed-length.test \
        gir/async-result-pos.test \
        gir/async-sync-out.test \
@@ -719,6 +720,7 @@ TESTS = \
        gir/property-non-readable.test \
        gir/symbol-type-csuffix.test \
        gir/union.test \
+       gir/union-transparent.test \
        gtktemplate/gtkcallback-incompatible.test \
        gtktemplate/gtkcallback-unknown.test \
        gtktemplate/gtkchild-field-incompatible-type.test \
diff --git a/tests/gir/alias.test b/tests/gir/alias.test
new file mode 100644 (file)
index 0000000..132d32a
--- /dev/null
@@ -0,0 +1,14 @@
+GIR
+
+Input:
+
+<alias name="Foo" c:type="TestFoo">
+  <type name="gint" c:type="int"/>
+</alias>
+
+Output:
+
+[CCode (cheader_filename = "test.h")]
+[SimpleType]
+public struct Foo : int {
+}
index 578c0b82ed9d24bf162bac9808e2f967051c37fd..cf265569d21b4894a1551398a7c68e94231e6279 100644 (file)
@@ -2,6 +2,12 @@ GIR
 
 Input:
 
+<alias name="Bar" c:type="TestBar">
+  <type name="Foo" c:type="TestFoo"/>
+</alias>
+<alias name="IBar" c:type="TestIBar">
+  <type name="IFoo" c:type="TestIFoo"/>
+</alias>
 <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">
@@ -127,6 +133,11 @@ Input:
 
 Output:
 
+[CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
+public class Bar : Test.Foo {
+       [CCode (has_construct_function = false)]
+       protected Bar ();
+}
 [CCode (cheader_filename = "test.h", type_id = "test_foo_get_type ()")]
 public class Foo : GLib.Object, Test.IFoo {
        [CCode (has_construct_function = false)]
@@ -140,6 +151,9 @@ public class Foo : GLib.Object, Test.IFoo {
        public string prop { owned get; set construct; }
        public signal void sig (string arg);
 }
+[CCode (cheader_filename = "test.h")]
+public interface IBar : Test.IFoo, GLib.Object {
+}
 [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/union-transparent.test b/tests/gir/union-transparent.test
new file mode 100644 (file)
index 0000000..d2e8e16
--- /dev/null
@@ -0,0 +1,30 @@
+GIR
+
+Input:
+
+<record name="Foo" c:type="TestFoo">
+  <field name="u" writable="1">
+    <type name="guint" c:type="guint"/>
+  </field>
+  <union>
+    <field name="a" writable="1">
+      <array zero-terminated="0" fixed-size="2">
+        <type name="int" c:type="int*"/>
+      </array>
+    </field>
+    <field name="pad" readable="0" private="1">
+      <array zero-terminated="0" fixed-size="4">
+        <type name="guint" c:type="guint"/>
+      </array>
+    </field>
+  </union>
+</record>
+
+Output:
+
+[CCode (cheader_filename = "test.h", has_type_id = false)]
+public struct Foo {
+       public uint u;
+       [CCode (array_length = false)]
+       public weak int a[2];
+}