diff options
| author | 2025-11-16 12:11:18 +0100 | |
|---|---|---|
| committer | 2025-11-16 12:11:18 +0100 | |
| commit | 111e71e1511b2abff9176bd6c714c8da796f770e (patch) | |
| tree | 352b723c9144c844037447bd865a8366378df7a5 /test/06-goto.c | |
| parent | b0c0f2d2d885c5901de08ed08dba9fff079bf6e3 (diff) | |
basic automated testing
Diffstat (limited to 'test/06-goto.c')
| -rw-r--r-- | test/06-goto.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/06-goto.c b/test/06-goto.c new file mode 100644 index 0000000..075467c --- /dev/null +++ b/test/06-goto.c @@ -0,0 +1,32 @@ +/* EXPECT: +7 -> 14 +-3 -> 0 +0 -> 0 +2 -> 4 +*/ +int crz(int x) { +/* x <<= 1; while (x < 0) ++x; return x; */ + goto e; +a: + return x; +j: + ++x; + goto q; +b: + if (x < 0) + goto j; + goto a; +q: + goto b; +e: + x <<= 1; + goto b; +} + +int printf(const char *, ...); +int main(int n) { + n = 7, printf("%d -> %d\n", n, crz(n)); + n = -3, printf("%d -> %d\n", n, crz(n)); + n = 0, printf("%d -> %d\n", n, crz(n)); + n = 2, printf("%d -> %d\n", n, crz(n)); +} |