Commit eca294cd23

LemonBoy <thatlemon@gmail.com>
2020-01-06 00:18:26
Add run-translated-c test
1 parent cd39f6d
Changed files (1)
test/run_translated_c.zig
@@ -3,6 +3,23 @@ const tests = @import("tests.zig");
 const nl = std.cstr.line_sep;
 
 pub fn addCases(cases: *tests.RunTranslatedCContext) void {
+    cases.add("boolean values and expressions",
+        \\#include <stdlib.h>
+        \\static const _Bool false_val = 0;
+        \\static const _Bool true_val = 1;
+        \\void foo(int x, int y) {
+        \\    _Bool r = x < y;
+        \\    if (!r) abort();
+        \\    _Bool self = foo;
+        \\    if (self == false_val) abort();
+        \\}
+        \\int main(int argc, char **argv) {
+        \\    foo(2, 5);
+        \\    if (false_val == true_val) abort();
+        \\    return 0;
+        \\}
+    , "");
+
     cases.add("hello world",
         \\#define _NO_CRT_STDIO_INLINE 1
         \\#include <stdio.h>