From: Rico Tzschichholz Date: Sun, 7 Jan 2018 09:44:18 +0000 (+0100) Subject: tests: Add "dynamic" signal and property tests to increase coverage X-Git-Tag: 0.39.4~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd0a65b8311f2cb5331dde2850cbeb3bcadebb63;p=thirdparty%2Fvala.git tests: Add "dynamic" signal and property tests to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 8ba947c40..26424edcf 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -181,6 +181,7 @@ TESTS = \ objects/chainup.vala \ objects/classes.vala \ objects/constructors.vala \ + objects/dynamic.vala \ objects/generics.vala \ objects/initially-unowned.vala \ objects/fields.vala \ diff --git a/tests/objects/dynamic.vala b/tests/objects/dynamic.vala new file mode 100644 index 000000000..aa429432a --- /dev/null +++ b/tests/objects/dynamic.vala @@ -0,0 +1,35 @@ +class Foo : Object { + public signal void sig (); + public string prop { get; set; } +} + +bool success = false; + +void sig_cb () { + success = true; +} + +void sig_after_cb () { + assert (success); +} + +void main () { + var real = new Foo (); + dynamic Object foo = real; + + foo.prop = "foo"; + string s = foo.prop; + assert (s == "foo"); + + success = false; + var id1 = foo.sig.connect_after (sig_after_cb); + var id2 = foo.sig.connect (sig_cb); + real.sig (); + assert (success); + + success = false; + SignalHandler.disconnect (foo, id1); + SignalHandler.disconnect (foo, id2); + real.sig (); + assert (!success); +}