[vala/staging] tests: Add some constructor tests
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add some constructor tests
- Date: Wed, 17 May 2017 11:01:41 +0000 (UTC)
commit 8217b03bfaa436d2e1f77b7882271647a6fdc055
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Oct 8 21:12:59 2016 +0200
tests: Add some constructor tests
tests/Makefile.am | 1 +
tests/objects/constructors.vala | 31 +++++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 37bc653..9571dce 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -161,6 +161,7 @@ TESTS = \
delegates/bug772204.test \
objects/chainup.vala \
objects/classes.vala \
+ objects/constructors.vala \
objects/generics.vala \
objects/fields.vala \
objects/interfaces.vala \
diff --git a/tests/objects/constructors.vala b/tests/objects/constructors.vala
new file mode 100644
index 0000000..e5f7c92
--- /dev/null
+++ b/tests/objects/constructors.vala
@@ -0,0 +1,31 @@
+class Foo : Object {
+ public string foo { get; private set; }
+
+ protected Foo.pro () {
+ foo = "foo.protected";
+ }
+
+ private Foo () {
+ foo = "foo.private";
+ }
+}
+
+class Bar : Foo {
+ public Bar.pro () {
+ base.pro ();
+ }
+
+ public Bar () {
+ base ();
+ }
+}
+
+void main () {
+ Bar bar;
+
+ bar = new Bar ();
+ assert (bar.foo == "foo.private");
+
+ bar = new Bar.pro ();
+ assert (bar.foo == "foo.protected");
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]