1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/libc3/assert.h b/libc3/assert.h
index 55c8f93..8a419a0 100644
--- a/libc3/assert.h
+++ b/libc3/assert.h
@@ -13,17 +13,22 @@
#ifndef LIBC3_ASSERT_H
#define LIBC3_ASSERT_H
-#include "types.h"
+#include "env.h"
#include "io.h"
#ifdef DEBUG
# define assert(test) \
do { \
+ sw assert_line = __LINE__; \
if (! (test)) { \
+ if (g_c3_env.argv && g_c3_env.argv[0]) { \
+ err_write_1(g_c3_env.argv[0]); \
+ err_write_1(": "); \
+ } \
err_write_1("assertion failed: "); \
err_write_1(__FILE__); \
err_write_1(":"); \
- err_write_1(__LINE__); \
+ err_inspect_sw(&assert_line); \
err_write_1(": "); \
err_write_1(__func__); \
err_write_1(": "); \
diff --git a/libc3/io.c b/libc3/io.c
index 2139674..41b6eb7 100644
--- a/libc3/io.c
+++ b/libc3/io.c
@@ -19,30 +19,22 @@
sw err_inspect_ ## name (type x) \
{ \
sw r; \
- sw result = 0; \
- if ((r = buf_inspect_ ## name(&g_c3_env.err, x)) < 0) \
+ r = buf_inspect_ ## name(&g_c3_env.err, x); \
+ if (r < 0) \
return r; \
- result += r; \
- if ((r = buf_write_u8(&g_c3_env.err, '\n')) < 0) \
- return r; \
- result += r; \
buf_flush(&g_c3_env.err); \
- return result; \
+ return r; \
}
#define DEF_IO_INSPECT(name, type) \
sw io_inspect_ ## name (type x) \
{ \
sw r; \
- sw result = 0; \
- if ((r = buf_inspect_ ## name(&g_c3_env.out, x)) < 0) \
- return r; \
- result += r; \
- if ((r = buf_write_u8(&g_c3_env.out, '\n')) < 0) \
+ r = buf_inspect_ ## name(&g_c3_env.out, x); \
+ if (r < 0) \
return r; \
- result += r; \
buf_flush(&g_c3_env.out); \
- return result; \
+ return r; \
}
#define DEF_ERR_IO_INSPECT(name, type) \
diff --git a/test/call_test.c b/test/call_test.c
index 7089e3d..218d689 100644
--- a/test/call_test.c
+++ b/test/call_test.c
@@ -27,7 +27,7 @@
do { \
s_call call; \
s_str result; \
- call_init_1(&call, (test)); \
+ TEST_EQ(call_init_1(&call, (test)), &call); \
TEST_EQ(call_inspect(&call, &result), &result); \
TEST_STRNCMP(result.ptr.p, (test), result.size); \
TEST_EQ(result.size, strlen(test)); \