]> git.draconx.ca Git - gob-dx.git/blobdiff - tests/interface.at
Implement chaining of interface methods.
[gob-dx.git] / tests / interface.at
index c8e2a9c88d7f70668bf28f4e2bd18a64bedb37ce..61c42bb4f35ce8cab82437d8c0829e7f8c279597 100644 (file)
@@ -65,6 +65,7 @@ class $1 from $3]m4_default_nblank([
   (interface Test:Fooable)
 {
   interface Test:Fooable private int foo(G:Object *go)
+    onerror 88
   {
     $5
     abort();
@@ -291,3 +292,97 @@ Test:B foo called
 ])
 
 AT_CLEANUP
+
+AT_SETUP([interface method chaining])
+AT_KEYWORDS([runtime])dnl
+
+TEST_FOOABLE_IFACE()
+TEST_FOOABLE_IMPL([Test:A], [G:Object],
+  [puts("Test:A foo called"); return PARENT_HANDLER(go);])
+TEST_FOOABLE_IMPL([Test:B], [Test:A],
+  [puts("Test:B foo called"); return PARENT_HANDLER(go);])
+TEST_FOOABLE_IMPL([Test:C], [Test:B],
+  [puts("Test:C foo called"); return PARENT_HANDLER(go);])
+
+AT_DATA([main.c],
+[[#include <stdio.h>
+#include "test-fooable.h"
+#include "test-a.h"
+#include "test-b.h"
+#include "test-c.h"
+
+int main(void)
+{
+  int rc;
+
+  rc = test_foo(g_object_new(TEST_TYPE_C, NULL));
+  printf("%d\n", rc);
+  if (rc < 0)
+    return EXIT_FAILURE;
+
+  return 0;
+}
+]])
+
+TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
+
+AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
+  test-a.o test-b.o test-c.o test-fooable.o main.o])
+AT_CHECK([./main], [0], [Test:C foo called
+Test:B foo called
+Test:A foo called
+88
+])
+
+AT_CLEANUP
+
+AT_SETUP([interface method chaining (dynamic)])
+AT_KEYWORDS([runtime])dnl
+
+TEST_FOOABLE_IFACE()
+TEST_FOOABLE_IMPL_DYN([Test:A], [G:Object],
+  [puts("Test:A foo called"); return PARENT_HANDLER(go);])
+TEST_FOOABLE_IMPL_DYN([Test:B], [Test:A],
+  [puts("Test:B foo called"); return PARENT_HANDLER(go);])
+TEST_FOOABLE_IMPL_DYN([Test:C], [Test:B],
+  [puts("Test:C foo called"); return PARENT_HANDLER(go);])
+
+AT_DATA([main.c],
+[[#include <stdio.h>
+#include "test-fooable.h"
+#include "test-a.h"
+#include "test-a-mod.h"
+#include "test-b.h"
+#include "test-b-mod.h"
+#include "test-c.h"
+#include "test-c-mod.h"
+
+int main(void)
+{
+  int rc;
+
+  g_type_module_use(g_object_new(TEST_TYPE_A_MOD, NULL));
+  g_type_module_use(g_object_new(TEST_TYPE_B_MOD, NULL));
+  g_type_module_use(g_object_new(TEST_TYPE_C_MOD, NULL));
+
+  rc = test_foo(g_object_new(TEST_TYPE_C, NULL));
+  printf("%d\n", rc);
+  if (rc < 0)
+    return EXIT_FAILURE;
+
+  return 0;
+}
+]])
+
+TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
+
+AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main \
+  test-a.o test-a-mod.o test-b.o test-b-mod.o test-c.o test-c-mod.o \
+  test-fooable.o main.o])
+AT_CHECK([./main], [0], [Test:C foo called
+Test:B foo called
+Test:A foo called
+88
+])
+
+AT_CLEANUP