]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
tests: Add "assigned local variables" tests
authorRico Tzschichholz <ricotz@ubuntu.com>
Fri, 26 Oct 2018 07:12:21 +0000 (09:12 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 26 Oct 2018 07:16:04 +0000 (09:16 +0200)
tests/Makefile.am
tests/control-flow/assigned-local-variable.vala [new file with mode: 0644]

index afc6f25d8c9575fa13f0abaa124d3efbc5b228f4..ae97233734042013d5fccf645aac3b3a1e33206e 100644 (file)
@@ -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 (file)
index 0000000..7946d72
--- /dev/null
@@ -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 ();
+               }
+       }
+}