aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/stdlib.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-03-25 15:40:59 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-03-25 15:40:59 -0400
commit1f9147187d66e95a0ffedd4d5595ec98646b5fe1 (patch)
tree14281e5cbde8e15fae63953b72844fb1a11d6f73 /src/stdlib/stdlib.c
parentd88d8648dc7802fbeac2f28dc5f2ef8fdfe1a9e4 (diff)
Make docstring tests use an actual expression AST instead of text
matching
Diffstat (limited to 'src/stdlib/stdlib.c')
-rw-r--r--src/stdlib/stdlib.c22
1 files changed, 6 insertions, 16 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index ae61bd0c..d2800dcd 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -602,29 +602,19 @@ public void end_inspect(const void *expr, const TypeInfo_t *type)
}
__attribute__((nonnull))
-public void test_value(const void *expr, const TypeInfo_t *type, const char *expected)
+public void test_value(const void *expr, const void *expected, const TypeInfo_t *type)
{
Text_t expr_text = generic_as_text(expr, USE_COLOR, type);
- Text_t type_name = generic_as_text(NULL, false, type);
-
- Text_t expected_text = Text$from_str(expected);
- Text_t expr_plain = USE_COLOR ? generic_as_text(expr, false, type) : expr_text;
- bool success = Text$equal_values(expr_plain, expected_text);
- if (!success) {
- OptionalMatch_t colon = Text$find(expected_text, Text(":"), I_small(1));
- if (colon.index.small) {
- Text_t with_type = Text$concat(expr_plain, Text(" : "), type_name);
- success = Text$equal_values(with_type, expected_text);
- }
- }
+ Text_t expected_text = generic_as_text(expected, USE_COLOR, type);
+ bool success = Text$equal_values(expr_text, expected_text);
if (!success) {
print_stack_trace(stderr, 2, 4);
fprintf(stderr,
USE_COLOR
- ? "\n\x1b[31;7m ==================== TEST FAILED ==================== \x1b[0;1m\n\nYou expected: \x1b[36;1m%s\x1b[0m\n\x1b[1m But I got:\x1b[m %k\n\n"
- : "\n==================== TEST FAILED ====================\n\nYou expected: %s\n But I got: %k\n\n",
- expected, &expr_text);
+ ? "\n\x1b[31;7m ==================== TEST FAILED ==================== \x1b[0;1m\n\nYou expected: \x1b[m%k\x1b[0m\n\x1b[1m But I got:\x1b[m %k\n\n"
+ : "\n==================== TEST FAILED ====================\n\nYou expected: %k\n But I got: %k\n\n",
+ &expected_text, &expr_text);
fflush(stderr);
raise(SIGABRT);