summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2014-01-11 12:13:38 +0100
committerLuca Bruno <lucabru@src.gnome.org>2014-01-11 12:17:06 +0100
commit58259ec0ef06548786a0d650c568267f5a6f0f17 (patch)
tree7768b5d54c4ad38ccdf68eafc5b3c6211fd6c29d /tests
parent86bf398bdff96c03ffb34ef0a60d311557db5077 (diff)
downloadvala-58259ec0ef06548786a0d650c568267f5a6f0f17.tar.gz
Fix coalescing operator semantics check.
The left operand was not put in any code block before the check, thus it wasn't able to transform itself. Fixes bug 691514.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/control-flow/bug691514.vala23
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6a36a4dd3..141b0484b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -65,6 +65,7 @@ TESTS = \
control-flow/sideeffects.vala \
control-flow/bug652549.vala \
control-flow/bug665904.vala \
+ control-flow/bug691514.vala \
enums/enums.vala \
enums/bug673879.vala \
structs/structs.vala \
diff --git a/tests/control-flow/bug691514.vala b/tests/control-flow/bug691514.vala
new file mode 100644
index 000000000..661e73c04
--- /dev/null
+++ b/tests/control-flow/bug691514.vala
@@ -0,0 +1,23 @@
+public string[] test() throws Error {
+ return { null, "1" };
+}
+
+void main() {
+ string t = (true ? "1" : "2") ?? "3";
+ assert (t == "1");
+
+ t = (false ? "1" : "2") ?? "3";
+ assert (t == "2");
+
+ t = (true ? null : "2") ?? "3";
+ assert (t == "3");
+
+ t = (false ? "1" : null) ?? "3";
+ assert (t == "3");
+
+ t = test()[0] ?? "2";
+ assert (t == "2");
+
+ t = test()[1] ?? "2";
+ assert (t == "1");
+}