]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add a bunch of chain-up tests
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 4 Nov 2016 17:06:37 +0000 (18:06 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sun, 5 Mar 2017 14:20:43 +0000 (15:20 +0100)
https://bugzilla.gnome.org/show_bug.cgi?id=567269

tests/Makefile.am
tests/chainup/class-base-foo.vala [new file with mode: 0644]
tests/chainup/class-base.vala [new file with mode: 0644]
tests/chainup/class-object.vala [new file with mode: 0644]
tests/chainup/class-this-foo.vala [new file with mode: 0644]
tests/chainup/class-this.vala [new file with mode: 0644]
tests/chainup/no-chainup.vala [new file with mode: 0644]
tests/chainup/struct-base-foo.vala [new file with mode: 0644]
tests/chainup/struct-base.vala [new file with mode: 0644]
tests/chainup/struct-this-foo.vala [new file with mode: 0644]
tests/chainup/struct-this.vala [new file with mode: 0644]

index 666f11011b9f05c019814265bcc0c3cf00add4a6..c656d2004325ec6e110e0a1902278df3508ad11a 100644 (file)
@@ -44,6 +44,16 @@ TESTS = \
        basic-types/bug761307.vala \
        basic-types/bug771626.test \
        basic-types/bug777697.test \
+       chainup/class-base.vala \
+       chainup/class-base-foo.vala \
+       chainup/class-object.vala \
+       chainup/class-this.vala \
+       chainup/class-this-foo.vala \
+       chainup/no-chainup.vala \
+       chainup/struct-base.vala \
+       chainup/struct-base-foo.vala \
+       chainup/struct-this.vala \
+       chainup/struct-this-foo.vala \
        pointers/bug590641.vala \
        namespaces.vala \
        methods/lambda.vala \
diff --git a/tests/chainup/class-base-foo.vala b/tests/chainup/class-base-foo.vala
new file mode 100644 (file)
index 0000000..606d719
--- /dev/null
@@ -0,0 +1,20 @@
+public class Foo {
+       public int i;
+       public Foo.foo () {
+               i = 1;
+       }
+}
+
+public class Bar : Foo {
+       public int j;
+       public Bar () {
+               base.foo ();
+               j = 1;
+       }
+}
+
+void main () {
+       var bar = new Bar ();
+       assert (bar.i == 1);
+       assert (bar.j == 1);
+}
diff --git a/tests/chainup/class-base.vala b/tests/chainup/class-base.vala
new file mode 100644 (file)
index 0000000..1bec7e4
--- /dev/null
@@ -0,0 +1,20 @@
+public class Foo {
+       public int i;
+       public Foo () {
+               i = 1;
+       }
+}
+
+public class Bar : Foo {
+       public int j;
+       public Bar () {
+               base ();
+               this.j = 1;
+       }
+}
+
+void main () {
+       var bar = new Bar ();
+       assert (bar.i == 1);
+       assert (bar.j == 1);
+}
diff --git a/tests/chainup/class-object.vala b/tests/chainup/class-object.vala
new file mode 100644 (file)
index 0000000..1d6b0d7
--- /dev/null
@@ -0,0 +1,12 @@
+public class Foo : Object {
+       public int i;
+       public Foo () {
+               Object ();
+               i = 1;
+       }
+}
+
+void main () {
+       var foo = new Foo ();
+       assert (foo.i == 1);
+}
diff --git a/tests/chainup/class-this-foo.vala b/tests/chainup/class-this-foo.vala
new file mode 100644 (file)
index 0000000..41b3b20
--- /dev/null
@@ -0,0 +1,17 @@
+public class Foo {
+       public int i;
+       public int j;
+       public Foo () {
+               this.foo ();
+               j = 1;
+       }
+       public Foo.foo () {
+               i = 1;
+       }
+}
+
+void main () {
+       var foo = new Foo ();
+       assert (foo.i == 1);
+       assert (foo.j == 1);
+}
diff --git a/tests/chainup/class-this.vala b/tests/chainup/class-this.vala
new file mode 100644 (file)
index 0000000..bc09171
--- /dev/null
@@ -0,0 +1,17 @@
+public class Foo {
+       public int i;
+       public int j;
+       public Foo () {
+               j = 1;
+       }
+       public Foo.bar () {
+               this ();
+               i = 1;
+       }
+}
+
+void main () {
+       var foo = new Foo.bar ();
+       assert (foo.i == 1);
+       assert (foo.j == 1);
+}
diff --git a/tests/chainup/no-chainup.vala b/tests/chainup/no-chainup.vala
new file mode 100644 (file)
index 0000000..d164bb3
--- /dev/null
@@ -0,0 +1,21 @@
+public class Foo {
+       int i;
+       public Foo () {
+               i = 0;
+       }
+
+       public Foo.foo () {
+               SourceFunc f = () => true;
+               f ();
+       }
+}
+
+public struct Bar {
+       int i;
+       public Bar () {
+               i = 0;
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/struct-base-foo.vala b/tests/chainup/struct-base-foo.vala
new file mode 100644 (file)
index 0000000..44aeb3b
--- /dev/null
@@ -0,0 +1,20 @@
+public struct Foo {
+       public int i;
+       public int j;
+       public Foo.foo () {
+               i = 1;
+       }
+}
+
+public struct Bar : Foo {
+       public Bar () {
+               base.foo ();
+               this.j = 1;
+       }
+}
+
+void main () {
+       var bar = Bar ();
+       //FIXME assert (bar.i == 1);
+       assert (bar.j == 1);
+}
diff --git a/tests/chainup/struct-base.vala b/tests/chainup/struct-base.vala
new file mode 100644 (file)
index 0000000..b1622cc
--- /dev/null
@@ -0,0 +1,20 @@
+public struct Foo {
+       public int i;
+       public int j;
+       public Foo () {
+               i = 1;
+       }
+}
+
+public struct Bar : Foo {
+       public Bar () {
+               base ();
+               this.j = 1;
+       }
+}
+
+void main () {
+       var bar = Bar ();
+       assert (bar.i == 1);
+       assert (bar.j == 1);
+}
diff --git a/tests/chainup/struct-this-foo.vala b/tests/chainup/struct-this-foo.vala
new file mode 100644 (file)
index 0000000..c0e53be
--- /dev/null
@@ -0,0 +1,17 @@
+public struct Foo {
+       public int i;
+       public int j;
+       public Foo () {
+               this.foo ();
+               j = 1;
+       }
+       public Foo.foo () {
+               i = 1;
+       }
+}
+
+void main () {
+       var foo = Foo ();
+       //FIXME assert (foo.i == 1);
+       assert (foo.j == 1);
+}
diff --git a/tests/chainup/struct-this.vala b/tests/chainup/struct-this.vala
new file mode 100644 (file)
index 0000000..1619e04
--- /dev/null
@@ -0,0 +1,17 @@
+public struct Foo {
+       public int i;
+       public int j;
+       public Foo () {
+               j = 1;
+       }
+       public Foo.bar () {
+               this ();
+               i = 1;
+       }
+}
+
+void main () {
+       var foo = Foo.bar ();
+       assert (foo.i == 1);
+       assert (foo.j == 1);
+}