mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-04 01:25:04 +03:00
0c038365d7
* 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>
29 lines
952 B
Plaintext
29 lines
952 B
Plaintext
(load "Test.carp")
|
|
(use-all IO Test)
|
|
|
|
(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) ]
|
|
(IO.Raw.unlink! file-name)
|
|
(if (Result.error? &read?)
|
|
(Result.unsafe-from-error read?)
|
|
(Result.unsafe-from-success read?) )))))
|
|
|
|
(deftest test
|
|
(assert-nothing test
|
|
&(IO.getenv "thisdoesnotexist")
|
|
"getenv works on non-existant variable"
|
|
)
|
|
(assert-just test
|
|
&(IO.getenv "PATH")
|
|
"getenv works on existant variable"
|
|
)
|
|
(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" ))
|
|
)
|