From 2b454d1408846fe8ea31c3dce1551d8ebffa8d0d Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 15 Sep 2024 15:53:38 -0400 Subject: [PATCH] Fix up file test --- test/paths.tm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/test/paths.tm b/test/paths.tm index 996b6dd..946526b 100644 --- a/test/paths.tm +++ b/test/paths.tm @@ -23,12 +23,27 @@ func main(): >> tmpfile:write("Hello world") >> tmpfile:append("!") >> tmpfile:read() - = "Hello world!" + = "Hello world!"? >> tmpfile:read_bytes() - = [72[B], 101[B], 108[B], 108[B], 111[B], 32[B], 119[B], 111[B], 114[B], 108[B], 100[B], 33[B]] + = [72[B], 101[B], 108[B], 108[B], 111[B], 32[B], 119[B], 111[B], 114[B], 108[B], 100[B], 33[B]]? >> tmpdir:files():has(tmpfile) = yes + if tmp_lines := tmpfile:by_line(): + >> [line for line in tmp_lines] + = ["Hello world!"] + else: + fail("Couldn't read lines in $tmpfile") + + >> (./does-not-exist.xxx):read() + = !Text + >> (./does-not-exist.xxx):read_bytes() + = ![Byte] + if lines := (./does-not-exist.xxx):by_line(): + fail("I could read lines in a nonexistent file") + else: + pass + >> tmpfile:remove() >> tmpdir:files():has(tmpfile)