[vala/staging: 1/2] tests: Add runtime checks to signals tests and increase coverage




commit 3e650c14e404e897dbfa76b48490aa93e5e4dfa0
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Nov 25 20:22:00 2021 +0100

    tests: Add runtime checks to signals tests and increase coverage

 tests/objects/signals.c-expected | 270 +++++++++++++++++++++++++++------------
 tests/objects/signals.vala       |  37 +++++-
 2 files changed, 217 insertions(+), 90 deletions(-)
---
diff --git a/tests/objects/signals.c-expected b/tests/objects/signals.c-expected
index 64684cc6d..66ce47005 100644
--- a/tests/objects/signals.c-expected
+++ b/tests/objects/signals.c-expected
@@ -1,8 +1,8 @@
 /* objects_signals.c generated by valac, the Vala compiler
  * generated from objects_signals.vala, do not modify */
 
-#include <glib-object.h>
 #include <glib.h>
+#include <glib-object.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -130,6 +130,10 @@ enum  {
 };
 static GParamSpec* maman_return_bar_properties[MAMAN_RETURN_BAR_NUM_PROPERTIES];
 #define _g_free0(var) (var = (g_free (var), NULL))
+#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
+#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, 
G_STRFUNC, msg); return; }
+#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning 
(G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
+#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, 
__LINE__, G_STRFUNC, msg);
 
 struct _MamanFoo {
        GObject parent_instance;
@@ -185,6 +189,8 @@ struct _MamanReturnBarClass {
        GObjectClass parent_class;
 };
 
+VALA_EXTERN gint counter;
+gint counter = 0;
 static gpointer maman_foo_parent_class = NULL;
 static gpointer maman_bar_parent_class = NULL;
 static gpointer maman_user_foo_parent_class = NULL;
@@ -222,12 +228,12 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (MamanUserFoo, g_object_unref)
 VALA_EXTERN void maman_user_foo_do_action (MamanUserFoo* self);
 VALA_EXTERN MamanUserFoo* maman_user_foo_new (void);
 VALA_EXTERN MamanUserFoo* maman_user_foo_construct (GType object_type);
-static void g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
-                                            GValue * return_value,
-                                            guint n_param_values,
-                                            const GValue * param_values,
-                                            gpointer invocation_hint,
-                                            gpointer marshal_data);
+static void g_cclosure_user_marshal_VOID__INT_INT_POINTER (GClosure * closure,
+                                                    GValue * return_value,
+                                                    guint n_param_values,
+                                                    const GValue * param_values,
+                                                    gpointer invocation_hint,
+                                                    gpointer marshal_data);
 static GType maman_user_foo_get_type_once (void);
 VALA_EXTERN GType maman_user_bar_get_type (void) G_GNUC_CONST ;
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (MamanUserBar, g_object_unref)
@@ -235,10 +241,12 @@ VALA_EXTERN void maman_user_bar_run (MamanUserBar* self);
 static void __lambda5_ (MamanUserBar* self,
                  MamanUserFoo* foo,
                  gint i1,
-                 gint i2);
+                 gint i2,
+                 gint* i3);
 static void ___lambda5__maman_user_foo_activated (MamanUserFoo* _sender,
                                            gint i1,
                                            gint i2,
+                                           gint* i3,
                                            gpointer self);
 VALA_EXTERN MamanUserBar* maman_user_bar_new (void);
 VALA_EXTERN MamanUserBar* maman_user_bar_construct (GType object_type);
@@ -345,13 +353,15 @@ maman_bar_activated (MamanBar* self,
        g_return_if_fail (MAMAN_IS_BAR (self));
        g_return_if_fail (MAMAN_IS_FOO (foo));
        if (b) {
+               g_assert_not_reached ();
+       } else {
                FILE* _tmp0_;
+               gint _tmp1_;
                _tmp0_ = stdout;
-               fprintf (_tmp0_, " BAD");
-       } else {
-               FILE* _tmp1_;
-               _tmp1_ = stdout;
-               fprintf (_tmp1_, " 5");
+               fprintf (_tmp0_, " 5");
+               counter = counter + 1;
+               _tmp1_ = counter;
+               _vala_assert (_tmp1_ == 5, "++counter == 5");
        }
 }
 
@@ -363,12 +373,20 @@ __lambda4_ (MamanBar* self,
        g_return_if_fail (MAMAN_IS_FOO (foo));
        if (b) {
                FILE* _tmp0_;
+               gint _tmp1_;
                _tmp0_ = stdout;
                fprintf (_tmp0_, " 8");
+               counter = counter + 1;
+               _tmp1_ = counter;
+               _vala_assert (_tmp1_ == 8, "++counter == 8");
        } else {
-               FILE* _tmp1_;
-               _tmp1_ = stdout;
-               fprintf (_tmp1_, " 4");
+               FILE* _tmp2_;
+               gint _tmp3_;
+               _tmp2_ = stdout;
+               fprintf (_tmp2_, " 4");
+               counter = counter + 1;
+               _tmp3_ = counter;
+               _vala_assert (_tmp3_ == 4, "++counter == 4");
        }
 }
 
@@ -392,32 +410,52 @@ void
 maman_bar_run (MamanBar* self)
 {
        FILE* _tmp0_;
+       gint _tmp1_;
        MamanFoo* foo = NULL;
-       MamanFoo* _tmp1_;
-       FILE* _tmp2_;
+       MamanFoo* _tmp2_;
        FILE* _tmp3_;
-       guint _tmp4_;
+       gint _tmp4_;
        FILE* _tmp5_;
-       FILE* _tmp6_;
+       gint _tmp6_;
+       guint _tmp7_;
+       FILE* _tmp8_;
+       gint _tmp9_;
+       FILE* _tmp10_;
+       gint _tmp11_;
        g_return_if_fail (MAMAN_IS_BAR (self));
        _tmp0_ = stdout;
        fprintf (_tmp0_, " 2");
-       _tmp1_ = maman_foo_new ();
-       foo = _tmp1_;
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 2, "++counter == 2");
+       _tmp2_ = maman_foo_new ();
+       foo = _tmp2_;
        g_signal_connect_object (foo, "activated", (GCallback) ___lambda4__maman_foo_activated, self, 0);
        g_signal_connect_object (foo, "activated", (GCallback) _maman_bar_activated_maman_foo_activated, 
self, 0);
-       _tmp2_ = stdout;
-       fprintf (_tmp2_, " 3");
-       maman_foo_do_action (foo, FALSE);
        _tmp3_ = stdout;
-       fprintf (_tmp3_, " 6");
-       g_signal_parse_name ("activated", MAMAN_TYPE_FOO, &_tmp4_, NULL, FALSE);
-       g_signal_handlers_disconnect_matched (foo, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | 
G_SIGNAL_MATCH_DATA, _tmp4_, 0, NULL, (GCallback) _maman_bar_activated_maman_foo_activated, self);
+       fprintf (_tmp3_, " 3");
+       counter = counter + 1;
+       _tmp4_ = counter;
+       _vala_assert (_tmp4_ == 3, "++counter == 3");
+       maman_foo_do_action (foo, FALSE);
        _tmp5_ = stdout;
-       fprintf (_tmp5_, " 7");
+       fprintf (_tmp5_, " 6");
+       counter = counter + 1;
+       _tmp6_ = counter;
+       _vala_assert (_tmp6_ == 6, "++counter == 6");
+       g_signal_parse_name ("activated", MAMAN_TYPE_FOO, &_tmp7_, NULL, FALSE);
+       g_signal_handlers_disconnect_matched (foo, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | 
G_SIGNAL_MATCH_DATA, _tmp7_, 0, NULL, (GCallback) _maman_bar_activated_maman_foo_activated, self);
+       _tmp8_ = stdout;
+       fprintf (_tmp8_, " 7");
+       counter = counter + 1;
+       _tmp9_ = counter;
+       _vala_assert (_tmp9_ == 7, "++counter == 7");
        maman_foo_do_action (foo, TRUE);
-       _tmp6_ = stdout;
-       fprintf (_tmp6_, " 9");
+       _tmp10_ = stdout;
+       fprintf (_tmp10_, " 9");
+       counter = counter + 1;
+       _tmp11_ = counter;
+       _vala_assert (_tmp11_ == 9, "++counter == 9");
        _g_object_unref0 (foo);
 }
 
@@ -472,8 +510,12 @@ maman_bar_get_type (void)
 void
 maman_user_foo_do_action (MamanUserFoo* self)
 {
+       gint i = 0;
+       gint _tmp0_ = 0;
        g_return_if_fail (MAMAN_IS_USER_FOO (self));
-       g_signal_emit (self, maman_user_foo_signals[MAMAN_USER_FOO_ACTIVATED_SIGNAL], 0, 6, -2);
+       g_signal_emit (self, maman_user_foo_signals[MAMAN_USER_FOO_ACTIVATED_SIGNAL], 0, 6, -2, &_tmp0_);
+       i = _tmp0_;
+       _vala_assert (i == 4, "i == 4");
 }
 
 MamanUserFoo*
@@ -491,20 +533,20 @@ maman_user_foo_new (void)
 }
 
 static void
-g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
-                                       GValue * return_value,
-                                       guint n_param_values,
-                                       const GValue * param_values,
-                                       gpointer invocation_hint,
-                                       gpointer marshal_data)
+g_cclosure_user_marshal_VOID__INT_INT_POINTER (GClosure * closure,
+                                               GValue * return_value,
+                                               guint n_param_values,
+                                               const GValue * param_values,
+                                               gpointer invocation_hint,
+                                               gpointer marshal_data)
 {
-       typedef void (*GMarshalFunc_VOID__INT_INT) (gpointer data1, gint arg_1, gint arg_2, gpointer data2);
-       register GMarshalFunc_VOID__INT_INT callback;
+       typedef void (*GMarshalFunc_VOID__INT_INT_POINTER) (gpointer data1, gint arg_1, gint arg_2, gpointer 
arg_3, gpointer data2);
+       register GMarshalFunc_VOID__INT_INT_POINTER callback;
        register GCClosure * cc;
        register gpointer data1;
        register gpointer data2;
        cc = (GCClosure *) closure;
-       g_return_if_fail (n_param_values == 3);
+       g_return_if_fail (n_param_values == 4);
        if (G_CCLOSURE_SWAP_DATA (closure)) {
                data1 = closure->data;
                data2 = param_values->data[0].v_pointer;
@@ -512,8 +554,8 @@ g_cclosure_user_marshal_VOID__INT_INT (GClosure * closure,
                data1 = param_values->data[0].v_pointer;
                data2 = closure->data;
        }
-       callback = (GMarshalFunc_VOID__INT_INT) (marshal_data ? marshal_data : cc->callback);
-       callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), data2);
+       callback = (GMarshalFunc_VOID__INT_INT_POINTER) (marshal_data ? marshal_data : cc->callback);
+       callback (data1, g_value_get_int (param_values + 1), g_value_get_int (param_values + 2), 
g_value_get_pointer (param_values + 3), data2);
 }
 
 static void
@@ -521,7 +563,7 @@ maman_user_foo_class_init (MamanUserFooClass * klass,
                            gpointer klass_data)
 {
        maman_user_foo_parent_class = g_type_class_peek_parent (klass);
-       maman_user_foo_signals[MAMAN_USER_FOO_ACTIVATED_SIGNAL] = g_signal_new ("activated", 
MAMAN_TYPE_USER_FOO, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT, G_TYPE_NONE, 2, 
G_TYPE_INT, G_TYPE_INT);
+       maman_user_foo_signals[MAMAN_USER_FOO_ACTIVATED_SIGNAL] = g_signal_new ("activated", 
MAMAN_TYPE_USER_FOO, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_INT_POINTER, 
G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_POINTER);
 }
 
 static void
@@ -555,42 +597,65 @@ static void
 __lambda5_ (MamanUserBar* self,
             MamanUserFoo* foo,
             gint i1,
-            gint i2)
+            gint i2,
+            gint* i3)
 {
+       gint _vala_i3 = 0;
        FILE* _tmp0_;
+       gint _tmp1_;
        g_return_if_fail (MAMAN_IS_USER_FOO (foo));
        _tmp0_ = stdout;
        fprintf (_tmp0_, " %d", i1 + i2);
+       _vala_i3 = i1 + i2;
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 4, "++counter == 4");
+       if (i3) {
+               *i3 = _vala_i3;
+       }
 }
 
 static void
 ___lambda5__maman_user_foo_activated (MamanUserFoo* _sender,
                                       gint i1,
                                       gint i2,
+                                      gint* i3,
                                       gpointer self)
 {
-       __lambda5_ ((MamanUserBar*) self, _sender, i1, i2);
+       __lambda5_ ((MamanUserBar*) self, _sender, i1, i2, i3);
 }
 
 void
 maman_user_bar_run (MamanUserBar* self)
 {
        FILE* _tmp0_;
+       gint _tmp1_;
        MamanUserFoo* foo = NULL;
-       MamanUserFoo* _tmp1_;
-       FILE* _tmp2_;
+       MamanUserFoo* _tmp2_;
        FILE* _tmp3_;
+       gint _tmp4_;
+       FILE* _tmp5_;
+       gint _tmp6_;
        g_return_if_fail (MAMAN_IS_USER_BAR (self));
        _tmp0_ = stdout;
        fprintf (_tmp0_, " 2");
-       _tmp1_ = maman_user_foo_new ();
-       foo = _tmp1_;
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 2, "++counter == 2");
+       _tmp2_ = maman_user_foo_new ();
+       foo = _tmp2_;
        g_signal_connect_object (foo, "activated", (GCallback) ___lambda5__maman_user_foo_activated, self, 0);
-       _tmp2_ = stdout;
-       fprintf (_tmp2_, " 3");
-       maman_user_foo_do_action (foo);
        _tmp3_ = stdout;
-       fprintf (_tmp3_, " 5");
+       fprintf (_tmp3_, " 3");
+       counter = counter + 1;
+       _tmp4_ = counter;
+       _vala_assert (_tmp4_ == 3, "++counter == 3");
+       maman_user_foo_do_action (foo);
+       _tmp5_ = stdout;
+       fprintf (_tmp5_, " 5");
+       counter = counter + 1;
+       _tmp6_ = counter;
+       _vala_assert (_tmp6_ == 5, "++counter == 5");
        _g_object_unref0 (foo);
 }
 
@@ -756,10 +821,14 @@ __lambda6_ (MamanReturnBar* self,
             gint arg)
 {
        FILE* _tmp0_;
+       gint _tmp1_;
        gint result = 0;
        g_return_val_if_fail (MAMAN_IS_RETURN_FOO (foo), 0);
        _tmp0_ = stdout;
        fprintf (_tmp0_, " %d", arg);
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 3, "++counter == 3");
        result = arg + 1;
        return result;
 }
@@ -780,14 +849,18 @@ __lambda7_ (MamanReturnBar* self,
             const gchar* arg)
 {
        FILE* _tmp0_;
-       gchar* _tmp1_;
+       gint _tmp1_;
+       gchar* _tmp2_;
        gchar* result = NULL;
        g_return_val_if_fail (MAMAN_IS_RETURN_FOO (foo), NULL);
        g_return_val_if_fail (arg != NULL, NULL);
        _tmp0_ = stdout;
        fprintf (_tmp0_, "%s", arg);
-       _tmp1_ = g_strdup (" 6");
-       result = _tmp1_;
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 5, "++counter == 5");
+       _tmp2_ = g_strdup (" 6");
+       result = _tmp2_;
        return result;
 }
 
@@ -805,31 +878,47 @@ void
 maman_return_bar_run (MamanReturnBar* self)
 {
        FILE* _tmp0_;
+       gint _tmp1_;
        MamanReturnFoo* foo = NULL;
-       MamanReturnFoo* _tmp1_;
-       FILE* _tmp2_;
-       gint _tmp3_ = 0;
-       FILE* _tmp4_;
-       gchar* _tmp5_ = NULL;
-       gchar* _tmp6_;
-       FILE* _tmp7_;
+       MamanReturnFoo* _tmp2_;
+       FILE* _tmp3_;
+       gint _tmp4_ = 0;
+       gint _tmp5_;
+       FILE* _tmp6_;
+       gchar* _tmp7_ = NULL;
+       gchar* _tmp8_;
+       gint _tmp9_;
+       FILE* _tmp10_;
+       gint _tmp11_;
        g_return_if_fail (MAMAN_IS_RETURN_BAR (self));
        _tmp0_ = stdout;
        fprintf (_tmp0_, " 2");
-       _tmp1_ = maman_return_foo_new ();
-       foo = _tmp1_;
+       counter = counter + 1;
+       _tmp1_ = counter;
+       _vala_assert (_tmp1_ == 2, "++counter == 2");
+       _tmp2_ = maman_return_foo_new ();
+       foo = _tmp2_;
        g_signal_connect_object (foo, "int-activated", (GCallback) 
___lambda6__maman_return_foo_int_activated, self, 0);
        g_signal_connect_object (foo, "string-activated", (GCallback) 
___lambda7__maman_return_foo_string_activated, self, 0);
-       _tmp2_ = stdout;
-       g_signal_emit (foo, maman_return_foo_signals[MAMAN_RETURN_FOO_INT_ACTIVATED_SIGNAL], 0, 3, &_tmp3_);
-       fprintf (_tmp2_, " %d", _tmp3_);
-       _tmp4_ = stdout;
-       g_signal_emit (foo, maman_return_foo_signals[MAMAN_RETURN_FOO_STRING_ACTIVATED_SIGNAL], 0, " 5", 
&_tmp5_);
-       _tmp6_ = _tmp5_;
-       fprintf (_tmp4_, "%s", _tmp6_);
-       _g_free0 (_tmp6_);
-       _tmp7_ = stdout;
-       fprintf (_tmp7_, " 7");
+       _tmp3_ = stdout;
+       g_signal_emit (foo, maman_return_foo_signals[MAMAN_RETURN_FOO_INT_ACTIVATED_SIGNAL], 0, 3, &_tmp4_);
+       fprintf (_tmp3_, " %d", _tmp4_);
+       counter = counter + 1;
+       _tmp5_ = counter;
+       _vala_assert (_tmp5_ == 4, "++counter == 4");
+       _tmp6_ = stdout;
+       g_signal_emit (foo, maman_return_foo_signals[MAMAN_RETURN_FOO_STRING_ACTIVATED_SIGNAL], 0, " 5", 
&_tmp7_);
+       _tmp8_ = _tmp7_;
+       fprintf (_tmp6_, "%s", _tmp8_);
+       _g_free0 (_tmp8_);
+       counter = counter + 1;
+       _tmp9_ = counter;
+       _vala_assert (_tmp9_ == 6, "++counter == 6");
+       _tmp10_ = stdout;
+       fprintf (_tmp10_, " 7");
+       counter = counter + 1;
+       _tmp11_ = counter;
+       _vala_assert (_tmp11_ == 7, "++counter == 7");
        _g_object_unref0 (foo);
 }
 
@@ -892,12 +981,15 @@ _vala_main (void)
        MamanUserBar* user_bar = NULL;
        MamanUserBar* _tmp4_;
        FILE* _tmp5_;
-       FILE* _tmp6_;
+       gint _tmp6_;
+       FILE* _tmp7_;
        MamanReturnBar* return_bar = NULL;
-       MamanReturnBar* _tmp7_;
-       FILE* _tmp8_;
+       MamanReturnBar* _tmp8_;
+       FILE* _tmp9_;
+       gint _tmp10_;
        _tmp0_ = stdout;
        fprintf (_tmp0_, "Signal Test: 1");
+       counter = 1;
        _tmp1_ = maman_bar_new ();
        bar = _tmp1_;
        maman_bar_run (bar);
@@ -905,18 +997,26 @@ _vala_main (void)
        fprintf (_tmp2_, " 10\n");
        _tmp3_ = stdout;
        fprintf (_tmp3_, "User Signal Test: 1");
+       counter = 1;
        _tmp4_ = maman_user_bar_new ();
        user_bar = _tmp4_;
        maman_user_bar_run (user_bar);
        _tmp5_ = stdout;
        fprintf (_tmp5_, " 6\n");
-       _tmp6_ = stdout;
-       fprintf (_tmp6_, "Signal Return Test: 1");
-       _tmp7_ = maman_return_bar_new ();
-       return_bar = _tmp7_;
+       counter = counter + 1;
+       _tmp6_ = counter;
+       _vala_assert (_tmp6_ == 6, "++counter == 6");
+       _tmp7_ = stdout;
+       fprintf (_tmp7_, "Signal Return Test: 1");
+       counter = 1;
+       _tmp8_ = maman_return_bar_new ();
+       return_bar = _tmp8_;
        maman_return_bar_run (return_bar);
-       _tmp8_ = stdout;
-       fprintf (_tmp8_, " 8\n");
+       _tmp9_ = stdout;
+       fprintf (_tmp9_, " 8\n");
+       counter = counter + 1;
+       _tmp10_ = counter;
+       _vala_assert (_tmp10_ == 8, "++counter == 8");
        _g_object_unref0 (return_bar);
        _g_object_unref0 (user_bar);
        _g_object_unref0 (bar);
diff --git a/tests/objects/signals.vala b/tests/objects/signals.vala
index 3e9764d94..9de25ac83 100644
--- a/tests/objects/signals.vala
+++ b/tests/objects/signals.vala
@@ -1,5 +1,7 @@
 using GLib;
 
+int counter;
+
 class Maman.Foo : Object {
        public signal void activated (bool b);
 
@@ -11,66 +13,81 @@ class Maman.Foo : Object {
 class Maman.Bar : Object {
        void activated (Foo foo, bool b) {
                if (b) {
-                       stdout.printf (" BAD");
+                       assert_not_reached ();
                } else {
                        stdout.printf (" 5");
+                       assert (++counter == 5);
                }
        }
 
        public void run () {
                stdout.printf (" 2");
+               assert (++counter == 2);
 
                var foo = new Foo ();
 
                foo.activated.connect ((foo, b) => {
                        if (b) {
                                stdout.printf (" 8");
+                               assert (++counter == 8);
                        } else {
                                stdout.printf (" 4");
+                               assert (++counter == 4);
                        }
                });
 
                foo.activated.connect (activated);
 
                stdout.printf (" 3");
+               assert (++counter == 3);
 
                foo.do_action (false);
 
                stdout.printf (" 6");
+               assert (++counter == 6);
 
                foo.activated.disconnect (activated);
 
                stdout.printf (" 7");
+               assert (++counter == 7);
 
                foo.do_action (true);
 
                stdout.printf (" 9");
+               assert (++counter == 9);
        }
 }
 
 class Maman.UserFoo : Object {
-       public signal void activated (int i1, int i2);
+       public signal void activated (int i1, int i2, out int i3);
 
        public void do_action () {
-               activated (6, -2);
+               int i;
+               activated (6, -2, out i);
+               assert (i == 4);
        }
 }
 
 class Maman.UserBar : Object {
        public void run () {
                stdout.printf (" 2");
+               assert (++counter == 2);
 
                var foo = new UserFoo ();
 
-               foo.activated.connect ((foo, i1, i2) => {
+               foo.activated.connect ((foo, i1, i2, out i3) => {
                        stdout.printf (" %d", i1 + i2);
+                       i3 = i1 + i2;
+                       assert (++counter == 4);
                });
 
                stdout.printf (" 3");
+               assert (++counter == 3);
 
                foo.do_action ();
 
                stdout.printf (" 5");
+               assert (++counter == 5);
        }
 }
 
@@ -82,29 +99,36 @@ class Maman.ReturnFoo : Object {
 class Maman.ReturnBar : Object {
        public void run () {
                stdout.printf (" 2");
+               assert (++counter == 2);
 
                var foo = new ReturnFoo ();
 
                foo.int_activated.connect ((foo, arg) => {
                        stdout.printf (" %d", arg);
+                       assert (++counter == 3);
                        return arg + 1;
                });
 
                foo.string_activated.connect ((foo, arg) => {
                        stdout.printf (arg);
+                       assert (++counter == 5);
                        return " 6";
                });
 
                stdout.printf (" %d", foo.int_activated (3));
+               assert (++counter == 4);
 
                stdout.printf (foo.string_activated (" 5"));
+               assert (++counter == 6);
 
                stdout.printf (" 7");
+               assert (++counter == 7);
        }
 }
 
 void main () {
        stdout.printf ("Signal Test: 1");
+       counter = 1;
 
        var bar = new Maman.Bar ();
        bar.run ();
@@ -112,17 +136,20 @@ void main () {
        stdout.printf (" 10\n");
 
        stdout.printf ("User Signal Test: 1");
+       counter = 1;
 
        var user_bar = new Maman.UserBar ();
        user_bar.run ();
 
        stdout.printf (" 6\n");
+       assert (++counter == 6);
 
        stdout.printf ("Signal Return Test: 1");
+       counter = 1;
 
        var return_bar = new Maman.ReturnBar ();
        return_bar.run ();
 
        stdout.printf (" 8\n");
+       assert (++counter == 8);
 }
-


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]