From c907d178d89dde5ad03b799b973b4ad0d360ffe3 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Wed, 3 May 2017 19:53:08 -0400 Subject: - Moved lux/data/error/exception to lux/control/exception. --- stdlib/test/test/lux/control/exception.lux | 47 +++++++++++++++++++++++++++ stdlib/test/test/lux/data/error/exception.lux | 47 --------------------------- 2 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 stdlib/test/test/lux/control/exception.lux delete mode 100644 stdlib/test/test/lux/data/error/exception.lux (limited to 'stdlib/test') diff --git a/stdlib/test/test/lux/control/exception.lux b/stdlib/test/test/lux/control/exception.lux new file mode 100644 index 000000000..80267cedd --- /dev/null +++ b/stdlib/test/test/lux/control/exception.lux @@ -0,0 +1,47 @@ +(;module: + lux + (lux [io] + (control monad + ["&" exception #+ exception:]) + (data [error #- fail] + [text] + text/format + [number]) + ["R" math/random]) + lux/test) + +(exception: Some-Exception) + +(exception: Another-Exception) + +(exception: Unknown-Exception) + +(test: "Exceptions" + [should-throw? R;bool + which? R;bool + should-catch? R;bool + default-val R;nat + some-val R;nat + another-val R;nat + otherwise-val R;nat + #let [this-ex (if should-catch? + (if which? + Some-Exception + Another-Exception) + Unknown-Exception) + expected (if should-throw? + (if should-catch? + (if which? + some-val + another-val) + otherwise-val) + default-val) + actual (|> (: (Error Nat) + (if should-throw? + (&;throw this-ex "Uh-oh...") + (&;return default-val))) + (&;catch Some-Exception (function [ex] some-val)) + (&;catch Another-Exception (function [ex] another-val)) + (&;otherwise (function [ex] otherwise-val)))]] + (assert "Catch and otherwhise handlers can properly handle the flow of exception-handling." + (n.= expected actual))) diff --git a/stdlib/test/test/lux/data/error/exception.lux b/stdlib/test/test/lux/data/error/exception.lux deleted file mode 100644 index 2a297a587..000000000 --- a/stdlib/test/test/lux/data/error/exception.lux +++ /dev/null @@ -1,47 +0,0 @@ -(;module: - lux - (lux [io] - (control monad) - (data [error #- fail] - (error ["&" exception #+ exception:]) - [text] - text/format - [number]) - ["R" math/random]) - lux/test) - -(exception: Some-Exception) - -(exception: Another-Exception) - -(exception: Unknown-Exception) - -(test: "Exceptions" - [should-throw? R;bool - which? R;bool - should-catch? R;bool - default-val R;nat - some-val R;nat - another-val R;nat - otherwise-val R;nat - #let [this-ex (if should-catch? - (if which? - Some-Exception - Another-Exception) - Unknown-Exception) - expected (if should-throw? - (if should-catch? - (if which? - some-val - another-val) - otherwise-val) - default-val) - actual (|> (: (Error Nat) - (if should-throw? - (&;throw this-ex "Uh-oh...") - (&;return default-val))) - (&;catch Some-Exception (function [ex] some-val)) - (&;catch Another-Exception (function [ex] another-val)) - (&;otherwise (function [ex] otherwise-val)))]] - (assert "Catch and otherwhise handlers can properly handle the flow of exception-handling." - (n.= expected actual))) -- cgit v1.2.3