| ... | @@ -18,7 +18,46 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -18,7 +18,46 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 18 | \\pub extern fn bar() c_int; | 18 | \\pub extern fn bar() c_int; |
| 19 | ); | 19 | ); |
| 20 | | 20 | |
| | 21 | cases.add_both("simple var decls", |
| | 22 | \\void foo(void) { |
| | 23 | \\ int a; |
| | 24 | \\ char b = 123; |
| | 25 | \\ const int c; |
| | 26 | \\ const unsigned d = 440; |
| | 27 | \\} |
| | 28 | , |
| | 29 | \\pub fn foo() void { |
| | 30 | \\ var a: c_int = undefined; |
| | 31 | \\ var b: u8 = u8(123); |
| | 32 | \\ const c: c_int = undefined; |
| | 33 | \\ const d: c_uint = c_uint(440); |
| | 34 | \\} |
| | 35 | ); |
| | 36 | |
| | 37 | cases.add_both("ignore result, explicit function arguments", |
| | 38 | \\void foo(void) { |
| | 39 | \\ int a; |
| | 40 | \\ 1; |
| | 41 | \\ "hey"; |
| | 42 | \\ 1 + 1; |
| | 43 | \\ 1 - 1; |
| | 44 | \\ a = 1; |
| | 45 | \\} |
| | 46 | , |
| | 47 | \\pub fn foo() void { |
| | 48 | \\ var a: c_int = undefined; |
| | 49 | \\ _ = 1; |
| | 50 | \\ _ = c"hey"; |
| | 51 | \\ _ = (1 + 1); |
| | 52 | \\ _ = (1 - 1); |
| | 53 | \\ a = 1; |
| | 54 | \\} |
| | 55 | ); |
| | 56 | |
| 21 | /////////////// Cases that pass for only stage2 //////////////// | 57 | /////////////// Cases that pass for only stage2 //////////////// |
| | 58 | // TODO: restore these tests after removing "import mode" concept |
| | 59 | // https://github.com/ziglang/zig/issues/2780 |
| | 60 | |
| 22 | // cases.add_2("Parameterless function prototypes", | 61 | // cases.add_2("Parameterless function prototypes", |
| 23 | // \\void a() {} | 62 | // \\void a() {} |
| 24 | // \\void b(void) {} | 63 | // \\void b(void) {} |
| ... | @@ -39,8 +78,28 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -39,8 +78,28 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 39 | // \\pub extern fn bar() void {} | 78 | // \\pub extern fn bar() void {} |
| 40 | // ); | 79 | // ); |
| 41 | | 80 | |
| | 81 | cases.add_2("parameterless function prototypes", |
| | 82 | \\void a() {} |
| | 83 | \\void b(void) {} |
| | 84 | \\void c(); |
| | 85 | \\void d(void); |
| | 86 | , |
| | 87 | \\pub fn a(...) void {} |
| | 88 | \\pub fn b() void {} |
| | 89 | \\pub extern fn c(...) void; |
| | 90 | \\pub extern fn d() void; |
| | 91 | ); |
| | 92 | |
| 42 | /////////////// Cases for only stage1 which are TODO items for stage2 //////////////// | 93 | /////////////// Cases for only stage1 which are TODO items for stage2 //////////////// |
| 43 | | 94 | |
| | 95 | cases.add_both("simple function definition", |
| | 96 | \\void foo(void) {} |
| | 97 | \\static void bar(void) {} |
| | 98 | , |
| | 99 | \\pub fn foo() void {} |
| | 100 | \\pub fn bar() void {} |
| | 101 | ); |
| | 102 | |
| 44 | cases.add("macro with left shift", | 103 | cases.add("macro with left shift", |
| 45 | \\#define REDISMODULE_READ (1<<0) | 104 | \\#define REDISMODULE_READ (1<<0) |
| 46 | , | 105 | , |
| ... | @@ -132,7 +191,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { | ... | @@ -132,7 +191,7 @@ pub fn addCases(cases: *tests.TranslateCContext) void { |
| 132 | \\} | 191 | \\} |
| 133 | ); | 192 | ); |
| 134 | | 193 | |
| 135 | cases.add("ignore result", | 194 | cases.add("ignore result, no function arguments", |
| 136 | \\void foo() { | 195 | \\void foo() { |
| 137 | \\ int a; | 196 | \\ int a; |
| 138 | \\ 1; | 197 | \\ 1; |