aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-28 17:49:40 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-28 17:49:40 -0700
commitff028525e5421ee93182bbf19102d34d434286f3 (patch)
tree7d1472a5670e424d6b2c34bb63dcc34e45f2d389 /test/run_tests.cpp
parentd0a1901cb06bf9efaa4c78f9a990663aeb63ce85 (diff)
downloadzig-ff028525e5421ee93182bbf19102d34d434286f3.tar.gz
zig-ff028525e5421ee93182bbf19102d34d434286f3.zip
add test for calling the result of if-else expr
See #14
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 9959eba605..f41e44562a 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1425,6 +1425,19 @@ pub fn main(args: [][]u8) -> %void {
%%stdout.printf("OK\n");
}
)SOURCE", "OK\n");
+
+ add_simple_case("call result of if else expression", R"SOURCE(
+import "std.zig";
+fn a() -> []u8 { "a\n" }
+fn b() -> []u8 { "b\n" }
+fn f(x: bool) {
+ %%stdout.printf((if (x) a else b)());
+}
+pub fn main(args: [][]u8) -> %void {
+ f(true);
+ f(false);
+}
+ )SOURCE", "a\nb\n");
}