[vala/wip/bug567269: 1/2] tests: Add a bunch of chain-up tests



commit 1703ec649bd740f7a12aa6aaec272e6103e31658
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Nov 4 18:06:37 2016 +0100

    tests: Add a bunch of chain-up tests

 tests/Makefile.am                            |   21 +++++++++++++++++++++
 tests/chainup/class-base-foo-invalid.test    |   16 ++++++++++++++++
 tests/chainup/class-base-foo.vala            |   20 ++++++++++++++++++++
 tests/chainup/class-base-invalid.test        |   15 +++++++++++++++
 tests/chainup/class-base.vala                |   20 ++++++++++++++++++++
 tests/chainup/class-object-invalid.test      |   12 ++++++++++++
 tests/chainup/class-object.vala              |   12 ++++++++++++
 tests/chainup/class-this-foo-invalid.test    |   13 +++++++++++++
 tests/chainup/class-this-foo.vala            |   17 +++++++++++++++++
 tests/chainup/class-this-invalid.test        |   12 ++++++++++++
 tests/chainup/class-this.vala                |   17 +++++++++++++++++
 tests/chainup/class-with-lambda-invalid.test |   14 ++++++++++++++
 tests/chainup/class-with-lambda.vala         |   22 ++++++++++++++++++++++
 tests/chainup/no-chainup.vala                |   21 +++++++++++++++++++++
 tests/chainup/struct-base-foo-invalid.test   |   16 ++++++++++++++++
 tests/chainup/struct-base-foo.vala           |   20 ++++++++++++++++++++
 tests/chainup/struct-base-invalid.test       |   17 +++++++++++++++++
 tests/chainup/struct-base.vala               |   20 ++++++++++++++++++++
 tests/chainup/struct-this-foo-invalid.test   |   13 +++++++++++++
 tests/chainup/struct-this-foo.vala           |   17 +++++++++++++++++
 tests/chainup/struct-this-invalid.test       |   13 +++++++++++++
 tests/chainup/struct-this.vala               |   17 +++++++++++++++++
 22 files changed, 365 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba88951..32954fe 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -43,6 +43,27 @@ TESTS = \
        basic-types/bug756376.vala \
        basic-types/bug761307.vala \
        basic-types/bug771626.test \
+       chainup/class-base.vala \
+       chainup/class-base-foo.vala \
+       chainup/class-object.vala \
+       chainup/class-this.vala \
+       chainup/class-this-foo.vala \
+       chainup/class-with-lambda.vala \
+       chainup/no-chainup.vala \
+       chainup/struct-base.vala \
+       chainup/struct-base-foo.vala \
+       chainup/struct-this.vala \
+       chainup/struct-this-foo.vala \
+       chainup/class-base-foo-invalid.test \
+       chainup/class-base-invalid.test \
+       chainup/class-object-invalid.test \
+       chainup/class-this-foo-invalid.test \
+       chainup/class-this-invalid.test \
+       chainup/class-with-lambda-invalid.test \
+       chainup/struct-base-foo-invalid.test \
+       chainup/struct-base-invalid.test \
+       chainup/struct-this-foo-invalid.test \
+       chainup/struct-this-invalid.test \
        pointers/bug590641.vala \
        namespaces.vala \
        methods/lambda.vala \
diff --git a/tests/chainup/class-base-foo-invalid.test b/tests/chainup/class-base-foo-invalid.test
new file mode 100644
index 0000000..7f9293b
--- /dev/null
+++ b/tests/chainup/class-base-foo-invalid.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+public class Foo {
+       public Foo.foo () {}
+}
+
+public class Bar : Foo {
+       int i;
+       public Bar () {
+               i = 1;
+               base.foo ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-base-foo.vala b/tests/chainup/class-base-foo.vala
new file mode 100644
index 0000000..606d719
--- /dev/null
+++ b/tests/chainup/class-base-foo.vala
@@ -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-invalid.test b/tests/chainup/class-base-invalid.test
new file mode 100644
index 0000000..6137805
--- /dev/null
+++ b/tests/chainup/class-base-invalid.test
@@ -0,0 +1,15 @@
+Invalid Code
+
+public class Foo {
+}
+
+public class Bar : Foo {
+       int i;
+       public Bar () {
+               i = 1;
+               base ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-base.vala b/tests/chainup/class-base.vala
new file mode 100644
index 0000000..1bec7e4
--- /dev/null
+++ b/tests/chainup/class-base.vala
@@ -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-invalid.test b/tests/chainup/class-object-invalid.test
new file mode 100644
index 0000000..d9dd47d
--- /dev/null
+++ b/tests/chainup/class-object-invalid.test
@@ -0,0 +1,12 @@
+Invalid Code
+
+public class Foo : Object {
+       int i;
+       public Foo () {
+               i = 1;
+               Object ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-object.vala b/tests/chainup/class-object.vala
new file mode 100644
index 0000000..1d6b0d7
--- /dev/null
+++ b/tests/chainup/class-object.vala
@@ -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-invalid.test b/tests/chainup/class-this-foo-invalid.test
new file mode 100644
index 0000000..3e6c438
--- /dev/null
+++ b/tests/chainup/class-this-foo-invalid.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+public class Foo {
+       int i;
+       public Foo () {
+               i = 1;
+               this.foo ();
+       }
+       public Foo.foo () {}
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-this-foo.vala b/tests/chainup/class-this-foo.vala
new file mode 100644
index 0000000..41b3b20
--- /dev/null
+++ b/tests/chainup/class-this-foo.vala
@@ -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-invalid.test b/tests/chainup/class-this-invalid.test
new file mode 100644
index 0000000..171e928
--- /dev/null
+++ b/tests/chainup/class-this-invalid.test
@@ -0,0 +1,12 @@
+Invalid Code
+
+public class Foo {
+       int i;
+       public Foo.bar () {
+               i = 1;
+               this ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-this.vala b/tests/chainup/class-this.vala
new file mode 100644
index 0000000..bc09171
--- /dev/null
+++ b/tests/chainup/class-this.vala
@@ -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/class-with-lambda-invalid.test b/tests/chainup/class-with-lambda-invalid.test
new file mode 100644
index 0000000..a4addb7
--- /dev/null
+++ b/tests/chainup/class-with-lambda-invalid.test
@@ -0,0 +1,14 @@
+Invalid Code
+
+public class Foo : Object {
+       int i;
+
+       public Foo.with_foo () {
+               SourceFunc f = () => i==1;
+               f();
+               this ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/class-with-lambda.vala b/tests/chainup/class-with-lambda.vala
new file mode 100644
index 0000000..4f2fdba
--- /dev/null
+++ b/tests/chainup/class-with-lambda.vala
@@ -0,0 +1,22 @@
+public class Foo : Object {
+       public Foo.lambda_after () {
+               this ();
+               SourceFunc f = () => this != null;
+               f (); // silence unused warning
+       }
+
+       public Foo.lambda_before () {
+               SourceFunc f = () => {
+                       SourceFunc g = () => true;
+                       return g ();
+               };
+               this ();
+               f (); // silence unused warning
+       }
+}
+
+void main () {
+       Foo foo;
+       foo = new Foo.lambda_after ();
+       foo = new Foo.lambda_before ();
+}
diff --git a/tests/chainup/no-chainup.vala b/tests/chainup/no-chainup.vala
new file mode 100644
index 0000000..d164bb3
--- /dev/null
+++ b/tests/chainup/no-chainup.vala
@@ -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-invalid.test b/tests/chainup/struct-base-foo-invalid.test
new file mode 100644
index 0000000..fc47cf7
--- /dev/null
+++ b/tests/chainup/struct-base-foo-invalid.test
@@ -0,0 +1,16 @@
+Invalid Code
+
+public struct Foo {
+       int i;
+       public Foo.foo () {}
+}
+
+public struct Bar : Foo {
+       public Bar () {
+               i = 1;
+               base.foo ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/struct-base-foo.vala b/tests/chainup/struct-base-foo.vala
new file mode 100644
index 0000000..44aeb3b
--- /dev/null
+++ b/tests/chainup/struct-base-foo.vala
@@ -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-invalid.test b/tests/chainup/struct-base-invalid.test
new file mode 100644
index 0000000..e934991
--- /dev/null
+++ b/tests/chainup/struct-base-invalid.test
@@ -0,0 +1,17 @@
+Invalid Code
+
+public struct Foo {
+       int i;
+
+       public Foo () {}
+}
+
+public struct Bar : Foo {
+       public Bar () {
+               i = 1;
+               base ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/struct-base.vala b/tests/chainup/struct-base.vala
new file mode 100644
index 0000000..b1622cc
--- /dev/null
+++ b/tests/chainup/struct-base.vala
@@ -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-invalid.test b/tests/chainup/struct-this-foo-invalid.test
new file mode 100644
index 0000000..5f10f27
--- /dev/null
+++ b/tests/chainup/struct-this-foo-invalid.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+public struct Foo {
+       int i;
+       public Foo () {
+               i = 1;
+               this.foo ();
+       }
+       public Foo.foo () {}
+}
+
+void main () {
+}
diff --git a/tests/chainup/struct-this-foo.vala b/tests/chainup/struct-this-foo.vala
new file mode 100644
index 0000000..c0e53be
--- /dev/null
+++ b/tests/chainup/struct-this-foo.vala
@@ -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-invalid.test b/tests/chainup/struct-this-invalid.test
new file mode 100644
index 0000000..656e85e
--- /dev/null
+++ b/tests/chainup/struct-this-invalid.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+public struct Foo {
+       int i;
+       public Foo () {}
+       public Foo.foo () {
+               i = 1;
+               this ();
+       }
+}
+
+void main () {
+}
diff --git a/tests/chainup/struct-this.vala b/tests/chainup/struct-this.vala
new file mode 100644
index 0000000..1619e04
--- /dev/null
+++ b/tests/chainup/struct-this.vala
@@ -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);
+}


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