aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/stdlib.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-07-12 15:06:02 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-07-12 15:06:02 -0400
commit789497e2ca25c8189fb2466f34dda054d99453b1 (patch)
tree4c7c6bac0b17d68d6079f9074c01a6a2ec3859c6 /src/stdlib/stdlib.c
parent46b0dbc5a448249ddc9a6ce20465f0fa41de6d64 (diff)
Doctests now use equality checking instead of text comparisons
Diffstat (limited to 'src/stdlib/stdlib.c')
-rw-r--r--src/stdlib/stdlib.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index fa41cda6..2b4bd99c 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -517,34 +517,33 @@ public 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)
{
- Text_t expr_text = generic_as_text(expr, USE_COLOR, type);
- Text_t expected_text = generic_as_text(expected, USE_COLOR, type);
+ if (generic_equal(expr, expected, type))
+ return;
- bool success = Text$equal_values(expr_text, expected_text);
- if (!success) {
- print_stacktrace(stderr, 2);
- fprint(stderr, "");
- fflush(stderr);
-
- start_inspect(filename, start, end);
- end_inspect(expr, type);
- fflush(stdout);
+ print_stacktrace(stderr, 2);
+ fprint(stderr, "");
+ fflush(stderr);
- 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");
- }
+ start_inspect(filename, start, end);
+ end_inspect(expr, type);
+ fflush(stdout);
- fflush(stderr);
- raise(SIGABRT);
+ 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)