Fix up file test

This commit is contained in:
Bruce Hill 2024-09-15 15:53:38 -04:00
parent 33876323aa
commit 2b454d1408

View File

@ -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)