aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/control/region.lux
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/test/lux/control/region.lux42
1 files changed, 23 insertions, 19 deletions
diff --git a/stdlib/source/test/lux/control/region.lux b/stdlib/source/test/lux/control/region.lux
index 691bcbbce..d9f28e5db 100644
--- a/stdlib/source/test/lux/control/region.lux
+++ b/stdlib/source/test/lux/control/region.lux
@@ -26,23 +26,27 @@
["." / (#+ Region)
[//
["." thread (#+ Thread)]
- ["." exception (#+ exception:)]]]})
+ ["." exception (#+ Exception exception:)]]]})
(exception: oops)
-(template [<name> <success> <error>]
- [(def: (<name> result)
- (All [a] (-> (Try a) Bit))
- (case result
- (#try.Success _)
- <success>
-
- (#try.Failure _)
- <error>))]
+(def: (success? result)
+ (All [a] (-> (Try a) Bit))
+ (case result
+ (#try.Success _)
+ true
+
+ (#try.Failure _)
+ false))
- [success? #1 #0]
- [failure? #0 #1]
- )
+(def: (throws? exception result)
+ (All [e a] (-> (Exception e) (Try a) Bit))
+ (case result
+ (#try.Success _)
+ false
+
+ (#try.Failure error)
+ (exception.match? exception error)))
(def: (injection value)
(Injection (All [a] (All [! r] (Region r (Thread !) a))))
@@ -105,7 +109,7 @@
(enum.range n.enum 1 expected-clean-ups))]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
- (wrap (and (success? outcome)
+ (wrap (and (..success? outcome)
(n.= expected-clean-ups
actual-clean-ups))))))
(_.cover [/.fail]
@@ -124,7 +128,7 @@
_ (/.fail //@ (exception.construct ..oops []))]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
- (wrap (and (failure? outcome)
+ (wrap (and (..throws? ..oops outcome)
(n.= expected-clean-ups
actual-clean-ups))))))
(_.cover [/.throw]
@@ -143,10 +147,10 @@
_ (/.throw //@ ..oops [])]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
- (wrap (and (failure? outcome)
+ (wrap (and (..throws? ..oops outcome)
(n.= expected-clean-ups
actual-clean-ups))))))
- (_.cover [/.acquire]
+ (_.cover [/.acquire /.clean-up-error]
(thread.run
(do {! thread.monad}
[clean-up-counter (thread.box 0)
@@ -163,7 +167,7 @@
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
(wrap (and (or (n.= 0 expected-clean-ups)
- (failure? outcome))
+ (..throws? /.clean-up-error outcome))
(n.= expected-clean-ups
actual-clean-ups))))))
(_.cover [/.lift]
@@ -176,7 +180,7 @@
[_ (/.lift //@ (thread.write expected-clean-ups clean-up-counter))]
(wrap [])))
actual-clean-ups (thread.read clean-up-counter)]
- (wrap (and (success? outcome)
+ (wrap (and (..success? outcome)
(n.= expected-clean-ups
actual-clean-ups))))))
))))