diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 16:54:36 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-09-21 16:54:36 -0400 |
| commit | 1cec086a6034ad546977cae7aeaf4bb876d21970 (patch) | |
| tree | cd2889aea7ca830359ba329a3f82b96e706bcdee /src/stdlib/stdlib.c | |
| parent | 0ab878ff4f72f7f6f6f64c1fc5d8023cd19fbe82 (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/stdlib.c')
| -rw-r--r-- | src/stdlib/stdlib.c | 38 |
1 files changed, 1 insertions, 37 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); |
