X-Git-Url: http://git.draconx.ca/gitweb/gob-dx.git/blobdiff_plain/43115cbfefb29535b3e9da83ab247a7f24c6994b..1b42784146ab0d40637c80cf6064bafe679a5a0a:/tests/interface.at diff --git a/tests/interface.at b/tests/interface.at index c8e2a9c..61c42bb 100644 --- a/tests/interface.at +++ b/tests/interface.at @@ -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 +#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 +#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