From: Rico Tzschichholz Date: Sun, 14 Apr 2019 08:24:18 +0000 (+0200) Subject: test: Add "ownership mismatch" test for coalesce and conditional expression X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05c8d02355701cc4ee53170e00e5ae8889ae78b9;p=thirdparty%2Fvala.git test: Add "ownership mismatch" test for coalesce and conditional expression --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 27d80e860..0386292af 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -160,6 +160,8 @@ TESTS = \ control-flow/missing-break.test \ control-flow/missing-return.test \ control-flow/nested-conditional.vala \ + control-flow/ownership-mismatch-coalesce.test \ + control-flow/ownership-mismatch-conditional.test \ control-flow/switch.vala \ control-flow/sideeffects.vala \ control-flow/unassigned-captured-local-variable.test \ diff --git a/tests/control-flow/ownership-mismatch-coalesce.test b/tests/control-flow/ownership-mismatch-coalesce.test new file mode 100644 index 000000000..a0957e88b --- /dev/null +++ b/tests/control-flow/ownership-mismatch-coalesce.test @@ -0,0 +1,11 @@ +Invalid Code + +string? foo () { + return "foo"; +} + +void main () { + unowned string bar = "bar"; + + unowned string manam = foo () ?? bar; +} diff --git a/tests/control-flow/ownership-mismatch-conditional.test b/tests/control-flow/ownership-mismatch-conditional.test new file mode 100644 index 000000000..c9bfd2191 --- /dev/null +++ b/tests/control-flow/ownership-mismatch-conditional.test @@ -0,0 +1,12 @@ +Invalid Code + +string? foo () { + return "foo"; +} + +void main () { + unowned string bar = "bar"; + bool cond = true; + + unowned string manam = cond ? foo () : bar; +}