[vala/staging] tests: Add "assigned local variables" tests



commit 1938d5415ebc1c88eeb5694217808d407461b3ef
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Fri Oct 26 09:12:21 2018 +0200

    tests: Add "assigned local variables" tests

 tests/Makefile.am                               |  1 +
 tests/control-flow/assigned-local-variable.vala | 23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+)
---
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 ();
+               }
+       }
+}


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