-dnl Copyright © 2019 Nick Bowler
+dnl Copyright © 2019-2020 Nick Bowler
dnl License GPLv2+: GNU General Public License version 2 or any later version.
dnl This is free software: you are free to change and redistribute it.
dnl There is NO WARRANTY, to the extent permitted by law.
AT_CLEANUP
-dnl Dynamic types: check that we can call interface methods of dynamic types.
-AT_SETUP([dynamic interface implementation])
-AT_KEYWORDS([dynamic runtime interface])
+AT_SETUP([GOB2_CHECK min-version test])
-AT_DATA([iface.h],
-[[#define IF_TYPE_TEST if_test_get_type()
-
-typedef struct IFTestIface {
- GTypeInterface parent;
-
- void (*test)(GObject *obj);
-} IFTestIface;
-
-GType if_test_get_type(void);
-]])
-
-AT_DATA([test.gob],
-[[%{
-#include <stdio.h>
-#include "iface.h"
-%}
-
-class :Test from G:Object (dynamic)
- (interface IF:Test)
-{
- private const char *s = { "Hello, World!" };
- interface IF:Test private void test(G:Object *o)
- {
- Self *self = SELF(o);
- printf("%s\n", self->_priv->s);
- }
-}
-]])
-
-AT_DATA([mod.gob],
-[[%{
-#include "test.h"
-%}
-class :Mod from G:Type:Module
-{
- override (G:Type:Module) gboolean load(G:Type:Module *m)
- {
- test_register_type(m);
- return TRUE;
- }
-}
+AT_DATA([configure.ac],
+[[AC_PREREQ([2.62])
+AC_INIT([test], [0])
+AC_OUTPUT
]])
+AT_CHECK([$AUTOCONF && test -f configure || exit 77], [0], [ignore], [ignore])
-AT_DATA([main.c],
-[[#include "test.h"
-#include "mod.h"
-#include "iface.h"
+m4_define([MYVER],
+ m4_bpatsubst(m4_dquote(m4_defn([AT_PACKAGE_VERSION])), [[^][0-9.]]))
-GType if_test_get_type(void)
-{
- static GType type = 0;
- if (type == 0) {
- static const GTypeInfo info = {
- sizeof (IFTestIface),
- NULL,
- NULL,
- };
-
- type = g_type_register_static(G_TYPE_INTERFACE, "IFTest", &info, 0);
- }
- return type;
-}
-
-int main(void)
-{
- GTypeModule *m = g_object_new(TYPE_MOD, NULL);
- GObject *t;
+m4_define([MYVER_P1], m4_dquote(m4_reverse(m4_unquote(
+ m4_split(m4_defn([MYVER]), [[.]])))))
+m4_define([MYVER_P1], m4_join([.], m4_reverse(
+ m4_eval(m4_car(MYVER_P1)+1), m4_shift(MYVER_P1))))
- g_type_module_use(m);
- t = g_object_new(TYPE_TEST, NULL);
-
- g_return_val_if_fail(G_TYPE_CHECK_INSTANCE_TYPE(t, IF_TYPE_TEST),
- EXIT_FAILURE);
- G_TYPE_INSTANCE_GET_INTERFACE(t, IF_TYPE_TEST, IFTestIface)->test(t);
-
- return EXIT_SUCCESS;
-}
+AT_DATA([test.in], [[@GOB2@
]])
-AT_CHECK([gob2 mod.gob])
-AT_CHECK([gob2 test.gob])
-TEST_COMPILE_GOBJECT([mod.c], [0], [], [ignore])
-TEST_COMPILE_GOBJECT([test.c], [0], [], [ignore])
-TEST_COMPILE_GOBJECT([main.c], [0], [], [ignore])
-AT_CHECK([$CC $CFLAGS $LDFLAGS $LIBGOBJECT_LIBS -o main mod.o test.o main.o])
-AT_CHECK([./main], [0], [Hello, World!
-])
+cat >configure.ac <<EOF
+[m4@&t@_include([$builddir/gob2.m4])]
+[m4@&t@_pattern_forbid([^GOB2_])]
+[AC_INIT([gob2_check], [0])]
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER]))[)]
+GOB2=\`command -v \$GOB2\`
+[AC_CONFIG_FILES([test])]
+[AC_OUTPUT]
+EOF
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [0], [ignore])
+
+command -v gob2 >expout
+AT_CHECK([cat test], [0], [expout], [ignore])
+
+sed '/GOB2_CHECK/c\
+[GOB2_CHECK(]m4_dquote(m4_defn([MYVER_P1]))[)]' configure.ac >configure.new
+mv -f configure.new configure.ac
+AT_CHECK([$AUTOCONF --force])
+AT_CHECK([./configure], [1], [ignore], [ignore])
AT_CLEANUP