| ... | ... | @@ -4,18 +4,18 @@ const nl = std.cstr.line_sep; |
| 4 | 4 | |
| 5 | 5 | pub fn addCases(cases: *tests.RunTranslatedCContext) void { |
| 6 | 6 | cases.add("ternary operator", |
| 7 | | \\#include <assert.h> |
| 7 | \\#include <stdlib.h> |
| 8 | 8 | \\static int cnt = 0; |
| 9 | 9 | \\int foo() { cnt++; return 42; } |
| 10 | 10 | \\int main(int argc, char **argv) { |
| 11 | 11 | \\ short q = 3; |
| 12 | 12 | \\ signed char z0 = q?:1; |
| 13 | | \\ assert(z0 == 3); |
| 13 | \\ if (z0 != 3) abort(); |
| 14 | 14 | \\ int z1 = 3?:1; |
| 15 | | \\ assert(z1 == 3); |
| 15 | \\ if (z1 != 3) abort(); |
| 16 | 16 | \\ int z2 = foo()?:-1; |
| 17 | | \\ assert(z2 == 42); |
| 18 | | \\ assert(cnt == 1); |
| 17 | \\ if (z2 != 42) abort(); |
| 18 | \\ if (cnt != 1) abort(); |
| 19 | 19 | \\ return 0; |
| 20 | 20 | \\} |
| 21 | 21 | , ""); |