1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-25 01:37:19 +00:00

add test for calling ev/read on normal fd

The test is almost identical to the os/open + :write test.
The only difference is the content is read back in with :read, not slurp
This commit is contained in:
Ian Shehadeh 2022-01-06 19:35:30 -05:00
parent 938c5013c9
commit 8d8a6534e3

View File

@ -115,6 +115,19 @@
# Cast to string to enable comparison # Cast to string to enable comparison
(assert (= "123\n456\n" (string (slurp "unique.txt"))) "File writing 4.2") (assert (= "123\n456\n" (string (slurp "unique.txt"))) "File writing 4.2")
(os/rm "unique.txt")) (os/rm "unique.txt"))
# Test that the stream created by os/open can be read from
(assert-no-error "File reading 1.1"
(def outstream (os/open "unique.txt" :wct))
(defer (:close outstream)
(:write outstream "123\n")
(:write outstream "456\n"))
(def outstream (os/open "unique.txt" :r))
(defer (:close outstream)
(assert (= "123\n456\n" (string (:read outstream :all))) "File reading 1.2"))
(os/rm "unique.txt"))
# ev/gather # ev/gather