From 08a2311efd8b388cd431feb6000741f4a62da613 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 1 Dec 2015 21:19:38 -0700 Subject: support if conditionals --- test/run_tests.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test/run_tests.cpp') 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) { -- cgit v1.2.3