]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Add test case wip/null-conditional e73009f2e4de8190eb372f8bcc93d9de9b102712
authorRico Tzschichholz <ricotz@ubuntu.com>
Thu, 19 Dec 2019 09:18:30 +0000 (10:18 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Thu, 19 Dec 2019 09:18:30 +0000 (10:18 +0100)
tests/Makefile.am
tests/control-flow/bug761267.vala [new file with mode: 0644]

index 21bfb431e673e3f983c414e62d3706a08e9412cf..829629d3d541596db3960b570688d0e203fb81a8 100644 (file)
@@ -192,6 +192,7 @@ TESTS = \
        control-flow/bug691514.vala     \
        control-flow/bug736774-1.vala \
        control-flow/bug736774-2.vala \
+       control-flow/bug761267.vala \
        control-flow/bug790903.test \
        control-flow/bug790903-2.test \
        control-semantic/argument-extra.test \
diff --git a/tests/control-flow/bug761267.vala b/tests/control-flow/bug761267.vala
new file mode 100644 (file)
index 0000000..5c2e91c
--- /dev/null
@@ -0,0 +1,51 @@
+class Foo {
+       public int i = 42;
+
+       public Foo? foo () {
+               return null;
+       }
+
+       public void faz () {
+               assert_not_reached ();
+       }
+}
+
+void bar (Foo? f) {
+       {
+               int? j = f?.i;
+               assert (j == null);
+       }
+       {
+               int k = 23;
+               k = f?.i;
+               assert (k == 0);
+       }
+}
+
+void baz (Foo? f) {
+       {
+               int i = f?.i;
+               assert (i == 42);
+       }
+       {
+               int? j = 23;
+               j = f?.foo ()?.i;
+               assert (j == null);
+       }
+       {
+               int k = 23;
+               k = f?.foo ()?.i;
+               assert (k == 0);
+       }
+}
+
+void main () {
+       {
+               Foo? foo = null;
+               foo?.faz ();
+       }
+       {
+               bar (null);
+               baz (new Foo ());
+       }
+}