[vala/0.36] tests: Add "dynamic" signal and property tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.36] tests: Add "dynamic" signal and property tests to increase coverage
- Date: Tue, 16 Jan 2018 17:16:28 +0000 (UTC)
commit 0e356868c9122bdad0c5a0b55b046b576071e1c4
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sun Jan 7 10:44:18 2018 +0100
tests: Add "dynamic" signal and property tests to increase coverage
tests/Makefile.am | 1 +
tests/objects/dynamic.vala | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c16958c..eb4fdf9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -176,6 +176,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 0000000..aa42943
--- /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);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]