Carp/test/system.carp
sdilts 67a6eb5d4c Add and update tests for open-file
+ Add file test/system.carp to test open-file
+ Update test/regression.carp with the new interface for IO.read->EOF
2019-11-08 17:20:05 -07:00

20 lines
545 B
Plaintext

(load "Test.carp")
(use-all Test IO Result)
(defn open-existing-file? [filename]
(let [f (open-file filename "r")]
(match f
(Error _) false
(Success x) (do
(fclose x)
true))))
(deftest test
(assert-true test
(error? &(open-file "asfasdfafs.txt" "r"))
"An error is given when the file doesn't exist")
(assert-true test
(open-existing-file? "test/system.carp")
"files that exist are opened properly"))