2020-01-25 16:23:14 +03:00
|
|
|
(load "Test.carp")
|
|
|
|
(use-all IO Test)
|
|
|
|
|
2021-06-08 22:05:51 +03:00
|
|
|
(defn write-then-read [content file-name]
|
|
|
|
(let [ written? (IO.write-file content file-name) ]
|
|
|
|
(if (Result.error? &written?)
|
|
|
|
(Result.unsafe-from-error written?)
|
|
|
|
(let-do [ read? (IO.read-file file-name) ]
|
2021-06-17 18:33:10 +03:00
|
|
|
(IO.Raw.unlink! file-name)
|
2021-06-08 22:05:51 +03:00
|
|
|
(if (Result.error? &read?)
|
|
|
|
(Result.unsafe-from-error read?)
|
|
|
|
(Result.unsafe-from-success read?) )))))
|
|
|
|
|
2020-01-25 16:23:14 +03:00
|
|
|
(deftest test
|
2020-05-12 15:53:42 +03:00
|
|
|
(assert-nothing test
|
2021-06-17 18:33:10 +03:00
|
|
|
&(IO.getenv "thisdoesnotexist")
|
2020-05-12 15:53:42 +03:00
|
|
|
"getenv works on non-existant variable"
|
2020-01-25 16:23:14 +03:00
|
|
|
)
|
2020-05-12 15:53:42 +03:00
|
|
|
(assert-just test
|
2021-06-17 18:33:10 +03:00
|
|
|
&(IO.getenv "PATH")
|
2020-01-25 16:23:14 +03:00
|
|
|
"getenv works on existant variable"
|
|
|
|
)
|
2021-06-08 22:05:51 +03:00
|
|
|
(let [ data "Icke\n\tdette\n\tkieke mal,\nOochen, Flesch und Beene." ] ; include \n in test data!
|
|
|
|
(assert-equal test
|
|
|
|
data
|
|
|
|
&(write-then-read data "io_carp_testdata.txt")
|
|
|
|
"write-file then read-file" ))
|
2020-01-25 16:23:14 +03:00
|
|
|
)
|