Currently a test is considered a failure if it throws an exception.
Instead we could have a test be a zero arity function that returns some data structure representing success and failure. The test construct can then throw or not throw the appropriate eunit exception depending on what is returned.
To me it feels like it would be more fitting for an ML language to work with values and pure functions rather than exceptions.
Would also give us a clear way to make multiple assertions in a single test.
module assert
val all : list (fn () -> assertion) -> assertion
let all assertions =
assertions
|> list.find (fn testCase -> isFail (testCase ()))
|> option.orElse Pass
Taken from here: https://github.com/alpaca-lang/alpaca_lib/pull/10#discussion_r161378639
Currently a
test
is considered a failure if it throws an exception.Instead we could have a test be a zero arity function that returns some data structure representing success and failure. The test construct can then throw or not throw the appropriate eunit exception depending on what is returned.
To me it feels like it would be more fitting for an ML language to work with values and pure functions rather than exceptions.
Would also give us a clear way to make multiple assertions in a single test.