mirror of
https://github.com/carp-lang/Carp.git
synced 2024-09-11 05:25:28 +03:00
+ Add file test/system.carp to test open-file + Update test/regression.carp with the new interface for IO.read->EOF
20 lines
545 B
Plaintext
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"))
|