aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-01 21:19:38 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-01 21:19:38 -0700
commit08a2311efd8b388cd431feb6000741f4a62da613 (patch)
tree528ba0056e9a54583c91b0787b9d5ffcdcc11de7 /test
parent1ed926c3216016d73e83377a295869d8579e2fde (diff)
downloadzig-08a2311efd8b388cd431feb6000741f4a62da613.tar.gz
zig-08a2311efd8b388cd431feb6000741f4a62da613.zip
support if conditionals
Diffstat (limited to 'test')
-rw-r--r--test/run_tests.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 334c35220b..c9855e8606 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -189,6 +189,30 @@ static void add_compiling_test_cases(void) {
)SOURCE");
}
+ add_simple_case("if statements", R"SOURCE(
+ #link("c")
+ extern {
+ fn puts(s: *const u8) -> i32;
+ fn exit(code: i32) -> unreachable;
+ }
+
+ export fn _start() -> unreachable {
+ if 1 != 0 {
+ puts("1 is true");
+ } else {
+ puts("1 is false");
+ }
+ if 0 != 0 {
+ puts("0 is true");
+ } else if 1 - 1 != 0 {
+ puts("1 - 1 is true");
+ }
+ if !(0 != 0) {
+ puts("!0 is true");
+ }
+ exit(0);
+ }
+ )SOURCE", "1 is true\n!0 is true\n");
}
static void add_compile_failure_test_cases(void) {