diff options
Diffstat (limited to 'stdlib/source/test/lux/control/exception.lux')
-rw-r--r-- | stdlib/source/test/lux/control/exception.lux | 163 |
1 files changed, 82 insertions, 81 deletions
diff --git a/stdlib/source/test/lux/control/exception.lux b/stdlib/source/test/lux/control/exception.lux index 8d54fa893..599eb5863 100644 --- a/stdlib/source/test/lux/control/exception.lux +++ b/stdlib/source/test/lux/control/exception.lux @@ -1,8 +1,8 @@ (.module: [lux #* - [abstract/monad (#+ do)] + [abstract + [monad (#+ do)]] [data - ["." name] [number ["n" nat]] ["." text ("#@." equivalence) @@ -33,84 +33,85 @@ value0 report-element field1 report-element value1 report-element] - (<| (_.context (name.module (name-of /._))) + (<| (_.covering /._) + (_.with-cover [/.Exception]) ($_ _.and - (_.test (%.name (name-of /.return)) - (case (/.return expected) - (#try.Success actual) (n.= expected actual) - (#try.Failure _) false)) - (_.test (%.name (name-of /.throw)) - (case (/.throw ..an-exception []) - (#try.Success _) false - (#try.Failure _) true)) - (_.test (%.name (name-of /.construct)) - (case (/.throw ..an-exception []) - (#try.Success _) - false - - (#try.Failure message) - (text@= message (/.construct ..an-exception [])))) - (_.test (%.name (name-of /.match?)) - (/.match? ..an-exception - (/.construct ..an-exception []))) - (_.test (%.name (name-of /.assert)) - (case (/.assert ..an-exception [] assertion-succeeded?) - (#try.Success _) - assertion-succeeded? - - (#try.Failure message) - (and (not assertion-succeeded?) - (text@= message (/.construct ..an-exception []))))) - (_.test (%.name (name-of /.catch)) - (and (n.= expected - (|> (/.throw ..an-exception []) - (/.catch ..an-exception (function (_ ex) expected)) - (/.otherwise (function (_ ex) wrong)))) - (n.= expected - (|> (/.throw ..another-exception []) - (/.catch ..an-exception (function (_ ex) wrong)) - (/.catch ..another-exception (function (_ ex) expected)) - (/.otherwise (function (_ ex) wrong)))))) - (_.test (%.name (name-of /.otherwise)) - (n.= expected - (|> (/.throw ..another-exception []) - (/.catch ..an-exception (function (_ ex) wrong)) - (/.otherwise (function (_ ex) expected))))) - (_.test (%.name (name-of /.report)) - (let [report (/.report [field0 value0] - [field1 value1])] - (and (text.contains? field0 report) - (text.contains? value0 report) - (text.contains? field1 report) - (text.contains? value1 report)))) - (_.test (%.name (name-of /.enumerate)) - (let [enumeration (/.enumerate %.text (list field0 value0 field1 value1))] - (and (text.contains? field0 enumeration) - (text.contains? value0 enumeration) - (text.contains? field1 enumeration) - (text.contains? value1 enumeration)))) - (_.test (%.name (name-of /.with)) - (and (case (/.with ..an-exception [] (#try.Success expected)) - (#try.Success actual) (n.= expected actual) - (#try.Failure _) false) - (case (/.with ..an-exception [] (#try.Failure "")) - (#try.Success _) false - (#try.Failure message) (text@= message (/.construct ..an-exception []))) - (case (/.with ..an-exception [] - (: (Try Nat) - (/.throw ..another-exception []))) - (#try.Success _) - false - - (#try.Failure message) - (and (text.contains? (/.construct ..an-exception []) message) - (text.contains? (/.construct ..another-exception []) message))))) - (_.test (%.name (name-of /.exception:)) - (case (/.throw ..custom-exception [expected]) - (#try.Success _) - false - - (#try.Failure message) - (and (text.contains? ..label message) - (text.contains? (%.nat expected) message)))) + (_.cover [/.return] + (case (/.return expected) + (#try.Success actual) (n.= expected actual) + (#try.Failure _) false)) + (_.cover [/.throw] + (case (/.throw ..an-exception []) + (#try.Success _) false + (#try.Failure _) true)) + (_.cover [/.construct] + (case (/.throw ..an-exception []) + (#try.Success _) + false + + (#try.Failure message) + (text@= message (/.construct ..an-exception [])))) + (_.cover [/.match?] + (/.match? ..an-exception + (/.construct ..an-exception []))) + (_.cover [/.assert] + (case (/.assert ..an-exception [] assertion-succeeded?) + (#try.Success _) + assertion-succeeded? + + (#try.Failure message) + (and (not assertion-succeeded?) + (text@= message (/.construct ..an-exception []))))) + (_.cover [/.catch] + (and (n.= expected + (|> (/.throw ..an-exception []) + (/.catch ..an-exception (function (_ ex) expected)) + (/.otherwise (function (_ ex) wrong)))) + (n.= expected + (|> (/.throw ..another-exception []) + (/.catch ..an-exception (function (_ ex) wrong)) + (/.catch ..another-exception (function (_ ex) expected)) + (/.otherwise (function (_ ex) wrong)))))) + (_.cover [/.otherwise] + (n.= expected + (|> (/.throw ..another-exception []) + (/.catch ..an-exception (function (_ ex) wrong)) + (/.otherwise (function (_ ex) expected))))) + (_.cover [/.report] + (let [report (/.report [field0 value0] + [field1 value1])] + (and (text.contains? field0 report) + (text.contains? value0 report) + (text.contains? field1 report) + (text.contains? value1 report)))) + (_.cover [/.enumerate] + (let [enumeration (/.enumerate %.text (list field0 value0 field1 value1))] + (and (text.contains? field0 enumeration) + (text.contains? value0 enumeration) + (text.contains? field1 enumeration) + (text.contains? value1 enumeration)))) + (_.cover [/.with] + (and (case (/.with ..an-exception [] (#try.Success expected)) + (#try.Success actual) (n.= expected actual) + (#try.Failure _) false) + (case (/.with ..an-exception [] (#try.Failure "")) + (#try.Success _) false + (#try.Failure message) (text@= message (/.construct ..an-exception []))) + (case (/.with ..an-exception [] + (: (Try Nat) + (/.throw ..another-exception []))) + (#try.Success _) + false + + (#try.Failure message) + (and (text.contains? (/.construct ..an-exception []) message) + (text.contains? (/.construct ..another-exception []) message))))) + (_.cover [/.exception:] + (case (/.throw ..custom-exception [expected]) + (#try.Success _) + false + + (#try.Failure message) + (and (text.contains? ..label message) + (text.contains? (%.nat expected) message)))) )))) |