[vala/wip/tests] tests: Add "destructors" test to increase coverage



commit 9564db29b14a314ab1f377ac601407fe64048a52
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Mon Feb 5 18:14:21 2018 +0100

    tests: Add "destructors" test to increase coverage

 tests/Makefile.am              |    1 +
 tests/objects/destructors.vala |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 936d141..358b586 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -217,6 +217,7 @@ TESTS = \
        objects/classes.vala \
        objects/constructor-variadic.test \
        objects/constructors.vala \
+       objects/destructors.vala \
        objects/dynamic.vala \
        objects/generics.vala \
        objects/initially-unowned.vala \
diff --git a/tests/objects/destructors.vala b/tests/objects/destructors.vala
new file mode 100644
index 0000000..c25702e
--- /dev/null
+++ b/tests/objects/destructors.vala
@@ -0,0 +1,34 @@
+class Foo : Object {
+       class string s;
+
+       class construct {
+               assert (s == null);
+               s = "foo";
+       }
+
+       class ~Foo () {
+               assert (s == "foo");
+               s = null;
+       }
+}
+
+class Bar : Object {
+       string s;
+
+       construct {
+               assert (s == null);
+               s = "bar";
+       }
+
+       ~Bar () {
+               assert (s == "bar");
+               s = null;
+       }
+}
+
+void main () {
+       typeof (Foo);
+
+       var bar = new Bar ();
+       bar = null;
+}


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