]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "destructors" test to increase coverage
authorRico Tzschichholz <ricotz@ubuntu.com>
Mon, 5 Feb 2018 17:14:21 +0000 (18:14 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Mon, 5 Feb 2018 17:14:21 +0000 (18:14 +0100)
tests/Makefile.am
tests/objects/destructors.vala [new file with mode: 0644]

index 936d141f3fa99f3a211ebb752e783abcf5feda4e..358b5867fe5f7541d1846619e94798b71359354a 100644 (file)
@@ -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 (file)
index 0000000..c25702e
--- /dev/null
@@ -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;
+}