From 1cec086a6034ad546977cae7aeaf4bb876d21970 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 21 Sep 2025 16:54:36 -0400 Subject: Deprecate `>> x ... = val` form of doctests and rename them to 'debug logs', also add multi-expression support --- src/stdlib/stdlib.c | 38 +------------------------------------- src/stdlib/stdlib.h | 8 -------- 2 files changed, 1 insertion(+), 45 deletions(-) (limited to 'src/stdlib') 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); -- cgit v1.2.3