mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-05 04:44:12 +03:00
67a6eb5d4c
+ 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"))
|