aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/stdlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdlib/stdlib.c')
-rw-r--r--src/stdlib/stdlib.c38
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);