aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-08 03:59:37 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-08 03:59:37 -0700
commit0c84ecd19d0dbe6a98dd5e3f440cc9d7a78ea7d9 (patch)
treec05148fa68edb77dbdedb501d590e469e41f8567 /test/run_tests.cpp
parente1f498212c74c48d740b959484123478dec748ff (diff)
downloadzig-0c84ecd19d0dbe6a98dd5e3f440cc9d7a78ea7d9.tar.gz
zig-0c84ecd19d0dbe6a98dd5e3f440cc9d7a78ea7d9.zip
codegen: fix else if expression and maybe unwrap expr
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 71158e9327..cc93e188e3 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -936,7 +936,27 @@ pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
}
)SOURCE", "OK\n");
+
+ add_simple_case("else if expression", R"SOURCE(
+use "std.zig";
+pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
+ if (f(1) == 1) {
+ print_str("OK\n");
+ }
+ return 0;
}
+fn f(c: u8) -> u8 {
+ if (c == 0) {
+ 0
+ } else if (c == 1) {
+ 1
+ } else {
+ 2
+ }
+}
+ )SOURCE", "OK\n");
+}
+
////////////////////////////////////////////////////////////////////////////////////