Enhance chibicc

This commit is contained in:
Justine Tunney 2020-12-09 04:00:48 -08:00
parent 8da931a7f6
commit 9df2cef4c4
52 changed files with 2606 additions and 2004 deletions

View file

@ -17,9 +17,9 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/calls/calls.h"
#include "libc/errno.h"
#include "libc/runtime/runtime.h"
#include "libc/calls/calls.h"
#include "libc/sysv/consts/ok.h"
#include "libc/testlib/testlib.h"
@ -29,7 +29,9 @@ textstartup static void init(void) {
}
const void *const ctors[] initarray = {init};
TEST(access, readDirectory) { ASSERT_EQ(0, access("test/libc/", F_OK)); }
TEST(access, readDirectory) {
ASSERT_EQ(0, access("test/libc/", F_OK));
}
TEST(access, readThisCode) {
ASSERT_EQ(0, access("test/libc/access_test.c", R_OK));

View file

@ -26,6 +26,7 @@ TEST(cescapec, test) {
EXPECT_EQ('\\' | 'r' << 8, cescapec('\r'));
EXPECT_EQ('\\' | 'n' << 8, cescapec('\n'));
EXPECT_EQ('\\' | '0' << 8 | '0' << 16 | '0' << 24, cescapec(0));
EXPECT_EQ('\\' | '0' << 8 | '3' << 16 | '3' << 24, cescapec('\e'));
EXPECT_EQ('\\' | '1' << 8 | '7' << 16 | '7' << 24, cescapec(0x7F));
EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, cescapec(0xFF));
EXPECT_EQ('\\' | '3' << 8 | '7' << 16 | '7' << 24, cescapec(0xFFFF));

View file

@ -17,13 +17,14 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/calls/struct/timespec.h"
#include "libc/conv/conv.h"
#include "libc/macros.h"
#include "libc/runtime/gc.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/clock.h"
#include "libc/testlib/testlib.h"
#include "libc/time/time.h"
#include "libc/calls/struct/timespec.h"
#include "libc/x/x.h"
TEST(clock_gettime, testClockRealtime) {
@ -31,5 +32,5 @@ TEST(clock_gettime, testClockRealtime) {
struct timespec ts;
EXPECT_NE(-1, gettimeofday(&tv, NULL));
EXPECT_NE(-1, clock_gettime(CLOCK_REALTIME, &ts));
EXPECT_LT((unsigned)abs(ts.tv_sec - tv.tv_sec), 5u);
EXPECT_LT((unsigned)ABS(ts.tv_sec - tv.tv_sec), 5u);
}