From 111e71e1511b2abff9176bd6c714c8da796f770e Mon Sep 17 00:00:00 2001 From: lemon Date: Sun, 16 Nov 2025 12:11:18 +0100 Subject: basic automated testing --- test/06-goto.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test/06-goto.c (limited to 'test/06-goto.c') 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)); +} -- cgit v1.2.3