Carp/test/system.carp
guberathome 0c038365d7
IO.Raw (#1243)
* feat!: move C library wrapper funtions to IO.Raw

* docs: fixed doc string for (String.allocated?)

* docs: removed superfluous parameter names for defns

* fix: replaces IO.exit by System.exit

* fix: ./test/regression.carp for (IO.read->EOF)

* fix: ./test/system.carp

* feat: implemented IO.fwrite!

* feat!: removed IO.exit

* feat!: raw character input now returns Int instead of Char

* fix: removed irritating space chars

* fix: repaired ./example/carp_demo.carp

* fix: reverted System.exit to return an Int for SDL examples

* fix: removed System.exit!

Co-authored-by: guberatsie <gunnar.bernhardt@siemens.com>
2021-06-17 17:33:10 +02:00

20 lines
546 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"))