aboutsummaryrefslogtreecommitdiff
path: root/test/paths.tm
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-15 15:53:38 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-15 15:53:38 -0400
commit2b454d1408846fe8ea31c3dce1551d8ebffa8d0d (patch)
tree4f8df3644d4a04a8d0db41790cbd610ff0d9bb06 /test/paths.tm
parent33876323aa2e3b1994a60b294cfd3f7fd0b35f68 (diff)
Fix up file test
Diffstat (limited to 'test/paths.tm')
-rw-r--r--test/paths.tm19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/paths.tm b/test/paths.tm
index 996b6dde..946526bb 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)