aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/world/file.lux
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/source/test/lux/world/file.lux')
-rw-r--r--stdlib/source/test/lux/world/file.lux56
1 files changed, 28 insertions, 28 deletions
diff --git a/stdlib/source/test/lux/world/file.lux b/stdlib/source/test/lux/world/file.lux
index 451f4671b..808a09e0e 100644
--- a/stdlib/source/test/lux/world/file.lux
+++ b/stdlib/source/test/lux/world/file.lux
@@ -6,13 +6,13 @@
[abstract/monad (#+ do)]
[control
["." io (#+ IO)]
+ ["." try (#+ Try)]
[concurrency
["." promise]]
[security
["!" capability]]]
[data
["." binary (#+ Binary)]
- ["." error (#+ Error)]
["." text]
[number
["." int]]
@@ -36,9 +36,9 @@
(r@wrap (do promise.monad
[#let [path (format "temp_file_" (%.nat number))]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (IO (Error Bit))
- (error.lift io.monad (/.exists? io.monad /.system path)))]
+ (do (try.with io.monad)
+ [#let [check-existence! (: (IO (Try Bit))
+ (try.lift io.monad (/.exists? io.monad /.system path)))]
pre! check-existence!
file (!.use (:: /.system create-file) path)
post! check-existence!
@@ -48,21 +48,21 @@
post!
(not remains?)))))]
(_.assert "Can create/delete files."
- (error.default #0 result)))))
+ (try.default #0 result)))))
(def: (read-and-write number data)
(-> Nat Binary Test)
(r@wrap (do promise.monad
[#let [path (format "temp_file_" (%.nat number))]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) data)
content (!.use (:: file content) [])
_ (!.use (:: file delete) [])]
(wrap (:: binary.equivalence = data content))))]
(_.assert "Can write/read files."
- (error.default #0 result)))))
+ (try.default #0 result)))))
(def: #export test
Test
@@ -81,18 +81,18 @@
(wrap (do promise.monad
[#let [path "temp_file_2"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
read-size (!.use (:: file size) [])
_ (!.use (:: file delete) [])]
(wrap (n/= file-size read-size))))]
(_.assert "Can read file size."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_file_3"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
_ (!.use (:: file append) dataR)
@@ -102,18 +102,18 @@
(wrap (and (n/= (n/* 2 file-size) read-size)
(:: binary.equivalence =
dataL
- (error.assume (binary.slice 0 (dec file-size) content)))
+ (try.assume (binary.slice 0 (dec file-size) content)))
(:: binary.equivalence =
dataR
- (error.assume (binary.slice file-size (dec read-size) content)))))))]
+ (try.assume (binary.slice file-size (dec read-size) content)))))))]
(_.assert "Can append to files."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_dir_4"]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (IO (Error Bit))
- (error.lift io.monad (/.exists? io.monad /.system path)))]
+ (do (try.with io.monad)
+ [#let [check-existence! (: (IO (Try Bit))
+ (try.lift io.monad (/.exists? io.monad /.system path)))]
pre! check-existence!
dir (!.use (:: /.system create-directory) path)
post! check-existence!
@@ -123,12 +123,12 @@
post!
(not remains?)))))]
(_.assert "Can create/delete directories."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [file-path "temp_file_5"
dir-path "temp_dir_5"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[dir (!.use (:: /.system create-directory) dir-path)
file (!.use (:: /.system create-file) (format dir-path "/" file-path))
_ (!.use (:: file over-write) dataL)
@@ -137,13 +137,13 @@
_ (!.use (:: dir discard) [])]
(wrap (n/= file-size read-size))))]
(_.assert "Can create files inside of directories."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [file-path "temp_file_6"
dir-path "temp_dir_6"
inner-dir-path "inner_temp_dir_6"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[dir (!.use (:: /.system create-directory) dir-path)
pre-files (!.use (:: dir files) [])
pre-directories (!.use (:: dir directories) [])
@@ -161,11 +161,11 @@
(and (n/= 1 (list.size post-files))
(n/= 1 (list.size post-directories)))))))]
(_.assert "Can list files/directories inside a directory."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path "temp_file_7"]
result (promise.future
- (do (error.with io.monad)
+ (do (try.with io.monad)
[file (!.use (:: /.system create-file) path)
_ (!.use (:: file over-write) dataL)
_ (!.use (:: file modify) new-modified)
@@ -173,19 +173,19 @@
_ (!.use (:: file delete) [])]
(wrap (:: instant.equivalence = new-modified old-modified))))]
(_.assert "Can change the time of last modification."
- (error.default #0 result))))
+ (try.default #0 result))))
(wrap (do promise.monad
[#let [path0 (format "temp_file_8+0")
path1 (format "temp_file_8+1")]
result (promise.future
- (do (error.with io.monad)
- [#let [check-existence! (: (-> Path (IO (Error Bit)))
+ (do (try.with io.monad)
+ [#let [check-existence! (: (-> Path (IO (Try Bit)))
(|>> (/.exists? io.monad /.system)
- (error.lift io.monad)))]
+ (try.lift io.monad)))]
file0 (!.use (:: /.system create-file) path0)
_ (!.use (:: file0 over-write) dataL)
pre! (check-existence! path0)
- file1 (: (IO (Error (File IO))) ## TODO: Remove :
+ file1 (: (IO (Try (File IO))) ## TODO: Remove :
(!.use (:: file0 move) path1))
post! (check-existence! path0)
confirmed? (check-existence! path1)
@@ -194,5 +194,5 @@
(not post!)
confirmed?))))]
(_.assert "Can move a file from one path to another."
- (error.default #0 result))))
+ (try.default #0 result))))
))))