mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-01-31 11:37:35 +00:00
8da931a7f6
This program popped up on Hacker News recently. It's the only modern compiler I've ever seen that doesn't have dependencies and is easily modified. So I added all of the missing GNU extensions I like to use which means it might be possible soon to build on non-Linux and have third party not vendor gcc binaries.
58 lines
1.1 KiB
C
58 lines
1.1 KiB
C
#include "third_party/chibicc/test/test.h"
|
|
|
|
static int ret10(void) {
|
|
return 10;
|
|
}
|
|
|
|
int main() {
|
|
ASSERT((long)-5, -10 + (long)5);
|
|
ASSERT((long)-15, -10 - (long)5);
|
|
ASSERT((long)-50, -10 * (long)5);
|
|
ASSERT((long)-2, -10 / (long)5);
|
|
|
|
ASSERT(1, -2 < (long)-1);
|
|
ASSERT(1, -2 <= (long)-1);
|
|
ASSERT(0, -2 > (long)-1);
|
|
ASSERT(0, -2 >= (long)-1);
|
|
|
|
ASSERT(1, (long)-2 < -1);
|
|
ASSERT(1, (long)-2 <= -1);
|
|
ASSERT(0, (long)-2 > -1);
|
|
ASSERT(0, (long)-2 >= -1);
|
|
|
|
ASSERT(0, 2147483647 + 2147483647 + 2);
|
|
ASSERT((long)-1, ({
|
|
long x;
|
|
x = -1;
|
|
x;
|
|
}));
|
|
|
|
ASSERT(1, ({
|
|
char x[3];
|
|
x[0] = 0;
|
|
x[1] = 1;
|
|
x[2] = 2;
|
|
char *y = x + 1;
|
|
y[0];
|
|
}));
|
|
ASSERT(0, ({
|
|
char x[3];
|
|
x[0] = 0;
|
|
x[1] = 1;
|
|
x[2] = 2;
|
|
char *y = x + 1;
|
|
y[-1];
|
|
}));
|
|
ASSERT(5, ({
|
|
struct t {
|
|
char a;
|
|
} x, y;
|
|
x.a = 5;
|
|
y = x;
|
|
y.a;
|
|
}));
|
|
|
|
ASSERT(10, (1 ? ret10 : (void *)0)());
|
|
|
|
return 0;
|
|
}
|