From 710bf8391d600b940b80f2dbd45e94cd0f447f74 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 3 Dec 2011 14:52:54 +0000 Subject: Add some tests --- tests/math_assignment.c | 22 ++++++++++++++++++++++ tests/static-1.c | 9 +++++++++ tests/static-2.c | 4 ++++ 3 files changed, 35 insertions(+) create mode 100644 tests/math_assignment.c create mode 100644 tests/static-1.c create mode 100644 tests/static-2.c diff --git a/tests/math_assignment.c b/tests/math_assignment.c new file mode 100644 index 0000000..abc295e --- /dev/null +++ b/tests/math_assignment.c @@ -0,0 +1,22 @@ +int positive_test() { + int x = 0; + x += 5;//5 + x -= 2;//3 + x *= 9;//27 0x1b + x /= 2;//13 0xd + + x %= 7;//6 + x |= 8;//14 0xe + x ^= 3;//13 0xd + + x += 2 << 3;//13 + 16 = 29 0xd + x -= 4 >> 1;//29 - 2 = 27 0x1b + x &= 7;//3 + x <<= 5;//96 0x60 + x >>= 5;//3 + return x; +} + +int main(){ + return positive_test(); +} diff --git a/tests/static-1.c b/tests/static-1.c new file mode 100644 index 0000000..cbdf07a --- /dev/null +++ b/tests/static-1.c @@ -0,0 +1,9 @@ +// Files: static-1.c static-2.c +// pp2cc should be able to compile two files with the same function defined, +// but using static storage +static int f() { + return 1; +} +int main() { + return f(); +} diff --git a/tests/static-2.c b/tests/static-2.c new file mode 100644 index 0000000..9a2aed4 --- /dev/null +++ b/tests/static-2.c @@ -0,0 +1,4 @@ +// Part of static-1.c +static int f() { + return 2; +} -- cgit v1.2.1