aboutsummaryrefslogtreecommitdiff
path: root/stdlib/test
diff options
context:
space:
mode:
authorEduardo Julian2018-02-07 00:37:35 -0400
committerEduardo Julian2018-02-07 00:37:35 -0400
commit844a44f87bd03fc9c65e18149c6dd2ccf8e9cb32 (patch)
treed94e855ddf39c710f2cecf52f6e43851fdfb25d5 /stdlib/test
parent17d5280a5e05c70cdb0b2cf44606c186b000c7c1 (diff)
- Improved the way exceptions work.
Diffstat (limited to 'stdlib/test')
-rw-r--r--stdlib/test/test/lux/concurrency/actor.lux8
-rw-r--r--stdlib/test/test/lux/control/exception.lux2
-rw-r--r--stdlib/test/test/lux/control/region.lux4
-rw-r--r--stdlib/test/test/lux/world/file.lux38
-rw-r--r--stdlib/test/tests.lux9
5 files changed, 31 insertions, 30 deletions
diff --git a/stdlib/test/test/lux/concurrency/actor.lux b/stdlib/test/test/lux/concurrency/actor.lux
index a5403d7d8..685ab169b 100644
--- a/stdlib/test/test/lux/concurrency/actor.lux
+++ b/stdlib/test/test/lux/concurrency/actor.lux
@@ -5,7 +5,7 @@
["ex" exception])
(data [number]
text/format
- ["E" error])
+ ["e" error])
(concurrency ["P" promise "P/" Monad<Promise>]
["T" task]
["&" actor #+ actor: message:]))
@@ -27,7 +27,7 @@
cause)))))
(message: #export Counter
- (count! [increment Nat] state self Nat)
+ (count! {increment Nat} state self Nat)
(let [state' (n/+ increment state)]
(T.return [state' state'])))
@@ -64,9 +64,9 @@
(n/= +3 output-3))))]
(assert "Can send messages to actors."
(case result
- (#E.Success outcome)
+ (#e.Success outcome)
outcome
- (#E.Error error)
+ (#e.Error error)
false))))
))
diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux
index 40838875e..0da875e29 100644
--- a/stdlib/test/test/lux/control/exception.lux
+++ b/stdlib/test/test/lux/control/exception.lux
@@ -40,7 +40,7 @@
default-val)
actual (|> (: (E.Error Nat)
(if should-throw?
- (&.throw this-ex "Uh-oh...")
+ (&.throw this-ex [])
(&.return default-val)))
(&.catch Some-Exception (function [ex] some-val))
(&.catch Another-Exception (function [ex] another-val))
diff --git a/stdlib/test/test/lux/control/region.lux b/stdlib/test/test/lux/control/region.lux
index 8de498dce..98344fac9 100644
--- a/stdlib/test/test/lux/control/region.lux
+++ b/stdlib/test/test/lux/control/region.lux
@@ -59,7 +59,7 @@
(do (/.Monad<Region> @)
[_ (monad.map @ (/.acquire @@ count-clean-up)
(list.n/range +1 expected-clean-ups))
- _ (/.throw @@ Oops "")]
+ _ (/.throw @@ Oops [])]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
(wrap (and (error? outcome)
@@ -73,7 +73,7 @@
count-clean-up (function [value]
(do @
[_ (thread.update n/inc clean-up-counter)]
- (wrap (: (Error Unit) (ex.throw Oops "")))))]
+ (wrap (: (Error Unit) (ex.throw Oops [])))))]
outcome (/.run @
(do (/.Monad<Region> @)
[_ (monad.map @ (/.acquire @@ count-clean-up)
diff --git a/stdlib/test/test/lux/world/file.lux b/stdlib/test/test/lux/world/file.lux
index 388a52807..6f4e26e6d 100644
--- a/stdlib/test/test/lux/world/file.lux
+++ b/stdlib/test/test/lux/world/file.lux
@@ -4,7 +4,7 @@
(control [monad #+ do])
(concurrency ["P" promise]
["T" task])
- (data ["E" error]
+ (data ["e" error]
[text]
text/format
[number])
@@ -42,7 +42,7 @@
(wrap (and (not pre) post
deleted? (not remains?)))))]
(assert "Can create/delete files."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +1 code)))]
result (P.future
@@ -52,7 +52,7 @@
_ (@.delete file)]
(wrap (:: blob.Eq<Blob> = dataL output))))]
(assert "Can write/read files."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +2 code)))]
result (P.future
@@ -62,7 +62,7 @@
_ (@.delete file)]
(wrap (n/= file-size read-size))))]
(assert "Can read file size."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +3 code)))]
result (P.future
@@ -73,23 +73,23 @@
read-size (@.size file)
_ (@.delete file)]
(wrap (and (n/= (n/* +2 file-size) read-size)
- (:: blob.Eq<Blob> = dataL (E.assume (blob.slice +0 (n/dec file-size) output)))
- (:: blob.Eq<Blob> = dataR (E.assume (blob.slice file-size (n/dec read-size) output)))))))]
+ (:: blob.Eq<Blob> = dataL (e.assume (blob.slice +0 (n/dec file-size) output)))
+ (:: blob.Eq<Blob> = dataR (e.assume (blob.slice file-size (n/dec read-size) output)))))))]
(assert "Can append to files."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [dir (format "temp_dir_" (%n (n/+ +4 code)))]
result (P.future
(do io.Monad<Process>
[pre (@.exists? dir)
- _ (@.make-dir dir)
+ _ (@.make-directory dir)
post (@.exists? dir)
deleted? (@.delete dir)
remains? (@.exists? dir)]
(wrap (and (not pre) post
deleted? (not remains?)))))]
(assert "Can create/delete directories."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +5 code)))
dir (format "temp_dir_" (%n (n/+ +5 code)))]
@@ -99,20 +99,20 @@
file-is-file (@.file? file)
file-is-directory (@.directory? file)
_ (@.delete file)
- _ (@.make-dir dir)
+ _ (@.make-directory dir)
directory-is-file (@.file? dir)
directory-is-directory (@.directory? dir)
_ (@.delete dir)]
(wrap (and file-is-file (not file-is-directory)
(not directory-is-file) directory-is-directory))))]
(assert "Can differentiate files from directories."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +6 code)))
dir (format "temp_dir_" (%n (n/+ +6 code)))]
result (P.future
(do io.Monad<Process>
- [_ (@.make-dir dir)
+ [_ (@.make-directory dir)
#let [file' (format dir "/" file)]
_ (@.write dataL file')
read-size (@.size file')
@@ -122,13 +122,13 @@
deleted-file
deleted-dir))))]
(assert "Can create files inside of directories."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +7 code)))
dir (format "temp_dir_" (%n (n/+ +7 code)))]
result (P.future
(do io.Monad<Process>
- [_ (@.make-dir dir)
+ [_ (@.make-directory dir)
#let [file' (format dir "/" file)]
_ (@.write dataL file')
children (@.files dir)
@@ -141,19 +141,19 @@
_
false))))]
(assert "Can list files inside a directory."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file (format "temp_file_" (%n (n/+ +8 code)))]
result (P.future
(do io.Monad<Process>
[_ (@.write dataL file)
- was-modified? (@.set-last-modified last-modified file)
- time-read (@.get-last-modified file)
+ was-modified? (@.modify last-modified file)
+ time-read (@.last-modified file)
_ (@.delete file)]
(wrap (and was-modified?
(:: i.Eq<Instant> = last-modified time-read)))))]
(assert "Can change the time of last modification."
- (E.default false result))))
+ (e.default false result))))
(wrap (do P.Monad<Promise>
[#let [file0 (format "temp_file_" (%n (n/+ +9 code)) "0")
file1 (format "temp_file_" (%n (n/+ +9 code)) "1")]
@@ -168,5 +168,5 @@
(wrap (and pre moved? (not post)
confirmed? deleted?))))]
(assert "Can move a file from one path to another."
- (E.default false result))))
+ (e.default false result))))
)))
diff --git a/stdlib/test/tests.lux b/stdlib/test/tests.lux
index 26a4212cc..98044e7d1 100644
--- a/stdlib/test/tests.lux
+++ b/stdlib/test/tests.lux
@@ -13,7 +13,8 @@
["_." atom]
["_." frp]
["_." promise]
- ["_." stm])
+ ["_." stm]
+ ["_." semaphore])
(control ["_." exception]
["_." interval]
["_." pipe]
@@ -68,15 +69,15 @@
(poly ["poly_." eq]
["poly_." functor]))
(type ["_." implicit]
- ["_." object])
+ ["_." object]
+ ["_." resource])
(lang ["lang/_." syntax]
["_." type]
(type ["_." check]))
(world ["_." blob]
["_." file]
(net ["_." tcp]
- ["_." udp]))
- ))
+ ["_." udp]))))
(lux (control [contract]
[concatenative]
[predicate])