aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-09-21 16:54:36 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-09-21 16:54:36 -0400
commit1cec086a6034ad546977cae7aeaf4bb876d21970 (patch)
treecd2889aea7ca830359ba329a3f82b96e706bcdee /src/stdlib
parent0ab878ff4f72f7f6f6f64c1fc5d8023cd19fbe82 (diff)
Deprecate `>> x ... = val` form of doctests and rename them to 'debugdoctests-to-debuglog
logs', also add multi-expression support
Diffstat (limited to 'src/stdlib')
-rw-r--r--src/stdlib/stdlib.c38
-rw-r--r--src/stdlib/stdlib.h8
2 files changed, 1 insertions, 45 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index 5ea8cb79..0756eab3 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -87,6 +87,7 @@ void start_inspect(const char *filename, int64_t start, int64_t end) {
if (file) {
size_t first_line_len = strcspn(file->text + start, "\r\n");
+ if (first_line_len > (size_t)(end - start)) first_line_len = (size_t)(end - start);
const char *slash = strrchr(filename, '/');
const char *file_base = slash ? slash + 1 : filename;
@@ -132,43 +133,6 @@ void end_inspect(const void *expr, const TypeInfo_t *type) {
}
}
-__attribute__((nonnull)) public
-void test_value(const char *filename, int64_t start, int64_t end, const void *expr, const void *expected,
- const TypeInfo_t *type) {
- if (generic_equal(expr, expected, type)) return;
-
- print_stacktrace(stderr, 2);
- fprint(stderr, "");
- fflush(stderr);
-
- start_inspect(filename, start, end);
- end_inspect(expr, type);
- fflush(stdout);
-
- Text_t expr_text = generic_as_text(expr, USE_COLOR, type);
- Text_t expected_text = generic_as_text(expected, USE_COLOR, type);
- if (USE_COLOR) {
- fprint(stderr,
- "\n\x1b[31;7m ==================== TEST FAILED ==================== \x1b[0;1m\n\n"
- "You expected: \x1b[m",
- expected_text,
- "\x1b[0m\n"
- "\x1b[1m But I got:\x1b[m ",
- expr_text, "\n");
- } else {
- fprint(stderr,
- "\n==================== TEST FAILED ====================\n\n"
- "You expected: ",
- expected_text,
- "\n"
- " But I got: ",
- expr_text, "\n");
- }
-
- fflush(stderr);
- raise(SIGABRT);
-}
-
public
void say(Text_t text, bool newline) {
Text$print(stdout, text);
diff --git a/src/stdlib/stdlib.h b/src/stdlib/stdlib.h
index 9bae5a6c..e52b5cd1 100644
--- a/src/stdlib/stdlib.h
+++ b/src/stdlib/stdlib.h
@@ -69,14 +69,6 @@ void end_inspect(const void *expr, const TypeInfo_t *type);
expr; \
end_inspect(NULL, typeinfo); \
}
-__attribute__((nonnull)) void test_value(const char *filename, int64_t start, int64_t end, const void *expr,
- const void *expected, const TypeInfo_t *type);
-#define test(type, expr, expected, typeinfo, start, end) \
- { \
- type _expr = expr; \
- type _expected = expected; \
- test_value(__SOURCE_FILE__, start, end, &_expr, &_expected, typeinfo); \
- }
void say(Text_t text, bool newline);
Text_t ask(Text_t prompt, bool bold, bool force_tty);