From: Rico Tzschichholz Date: Fri, 26 Oct 2018 07:12:21 +0000 (+0200) Subject: tests: Add "assigned local variables" tests X-Git-Tag: 0.43.1~169 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1938d5415ebc1c88eeb5694217808d407461b3ef;p=thirdparty%2Fvala.git tests: Add "assigned local variables" tests --- diff --git a/tests/Makefile.am b/tests/Makefile.am index afc6f25d8..ae9723373 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -130,6 +130,7 @@ TESTS = \ methods/printf-invalid.test \ methods/printf-constructor.vala \ methods/printf-constructor-invalid.test \ + control-flow/assigned-local-variable.vala \ control-flow/break.vala \ control-flow/break-invalid.test \ control-flow/continue-invalid.test \ diff --git a/tests/control-flow/assigned-local-variable.vala b/tests/control-flow/assigned-local-variable.vala new file mode 100644 index 000000000..7946d72ea --- /dev/null +++ b/tests/control-flow/assigned-local-variable.vala @@ -0,0 +1,23 @@ +bool foo (out string? s) { + s = "foo"; + return true; +} + +int bar () { + return 42; +} + +void main () { + { + string? s; + if (!foo (out s) || s == null) { + assert_not_reached (); + } + } + { + int i; + if ((i = bar ()) > 42 || i < 23) { + assert_not_reached (); + } + } +}