mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Add chibicc
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.
This commit is contained in:
parent
e44a0cf6f8
commit
8da931a7f6
298 changed files with 19493 additions and 11950 deletions
105
third_party/chibicc/test/string_test.c
vendored
Normal file
105
third_party/chibicc/test/string_test.c
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
#include "third_party/chibicc/test/test.h"
|
||||
|
||||
int main() {
|
||||
ASSERT(0, ""[0]);
|
||||
ASSERT(1, sizeof(""));
|
||||
|
||||
ASSERT(97, "abc"[0]);
|
||||
ASSERT(98, "abc"[1]);
|
||||
ASSERT(99, "abc"[2]);
|
||||
ASSERT(0, "abc"[3]);
|
||||
ASSERT(4, sizeof("abc"));
|
||||
|
||||
ASSERT(7, "\a"[0]);
|
||||
ASSERT(8, "\b"[0]);
|
||||
ASSERT(9, "\t"[0]);
|
||||
ASSERT(10, "\n"[0]);
|
||||
ASSERT(11, "\v"[0]);
|
||||
ASSERT(12, "\f"[0]);
|
||||
ASSERT(13, "\r"[0]);
|
||||
ASSERT(27, "\e"[0]);
|
||||
|
||||
ASSERT(106, "\j"[0]);
|
||||
ASSERT(107, "\k"[0]);
|
||||
ASSERT(108, "\l"[0]);
|
||||
|
||||
ASSERT(7, "\ax\ny"[0]);
|
||||
ASSERT(120, "\ax\ny"[1]);
|
||||
ASSERT(10, "\ax\ny"[2]);
|
||||
ASSERT(121, "\ax\ny"[3]);
|
||||
|
||||
ASSERT(0, "\0"[0]);
|
||||
ASSERT(16, "\20"[0]);
|
||||
ASSERT(65, "\101"[0]);
|
||||
ASSERT(104, "\1500"[0]);
|
||||
ASSERT(0, "\x00"[0]);
|
||||
ASSERT(119, "\x77"[0]);
|
||||
|
||||
ASSERT(7, sizeof("abc"
|
||||
"def"));
|
||||
ASSERT(9, sizeof("abc"
|
||||
"d"
|
||||
"efgh"));
|
||||
ASSERT(0, strcmp("abc"
|
||||
"d"
|
||||
"\nefgh",
|
||||
"abcd\nefgh"));
|
||||
ASSERT(0, !strcmp("abc"
|
||||
"d",
|
||||
"abcd\nefgh"));
|
||||
ASSERT(0, strcmp("\x9"
|
||||
"0",
|
||||
"\t0"));
|
||||
|
||||
ASSERT(16, sizeof(L"abc"
|
||||
""));
|
||||
|
||||
ASSERT(28, sizeof(L"abc"
|
||||
"def"));
|
||||
ASSERT(28, sizeof(L"abc"
|
||||
L"def"));
|
||||
ASSERT(14, sizeof(u"abc"
|
||||
"def"));
|
||||
ASSERT(14, sizeof(u"abc"
|
||||
u"def"));
|
||||
|
||||
ASSERT(L'a', (L"abc"
|
||||
"def")[0]);
|
||||
ASSERT(L'd', (L"abc"
|
||||
"def")[3]);
|
||||
ASSERT(L'\0', (L"abc"
|
||||
"def")[6]);
|
||||
|
||||
ASSERT(u'a', (u"abc"
|
||||
"def")[0]);
|
||||
ASSERT(u'd', (u"abc"
|
||||
"def")[3]);
|
||||
ASSERT(u'\0', (u"abc"
|
||||
"def")[6]);
|
||||
|
||||
ASSERT(L'あ', ("あ"
|
||||
L"")[0]);
|
||||
ASSERT(0343, ("\343\201\202"
|
||||
L"")[0]);
|
||||
ASSERT(0201, ("\343\201\202"
|
||||
L"")[1]);
|
||||
ASSERT(0202, ("\343\201\202"
|
||||
L"")[2]);
|
||||
ASSERT(0, ("\343\201\202"
|
||||
L"")[3]);
|
||||
|
||||
ASSERT(L'a', ("a"
|
||||
"b"
|
||||
L"c")[0]);
|
||||
ASSERT(L'b', ("a"
|
||||
"b"
|
||||
L"c")[1]);
|
||||
ASSERT(L'c', ("a"
|
||||
"b"
|
||||
L"c")[2]);
|
||||
ASSERT(0, ("a"
|
||||
"b"
|
||||
L"c")[3]);
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue