| ... | @@ -3,6 +3,23 @@ const tests = @import("tests.zig"); | ... | @@ -3,6 +3,23 @@ const tests = @import("tests.zig"); |
| 3 | const nl = std.cstr.line_sep; | 3 | const nl = std.cstr.line_sep; |
| 4 | | 4 | |
| 5 | pub fn addCases(cases: *tests.RunTranslatedCContext) void { | 5 | pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| | 6 | cases.add("variable shadowing type type", |
| | 7 | \\#include <stdlib.h> |
| | 8 | \\int main() { |
| | 9 | \\ int type = 1; |
| | 10 | \\ if (type != 1) abort(); |
| | 11 | \\} |
| | 12 | , ""); |
| | 13 | |
| | 14 | cases.add("assignment as expression", |
| | 15 | \\#include <stdlib.h> |
| | 16 | \\int main() { |
| | 17 | \\ int a, b, c, d = 5; |
| | 18 | \\ int e = a = b = c = d; |
| | 19 | \\ if (e != 5) abort(); |
| | 20 | \\} |
| | 21 | , ""); |
| | 22 | |
| 6 | cases.add("static variable in block scope", | 23 | cases.add("static variable in block scope", |
| 7 | \\#include <stdlib.h> | 24 | \\#include <stdlib.h> |
| 8 | \\int foo() { | 25 | \\int foo() { |