sageserpent-open / americium

Generation of test case data for Scala and Java, in the spirit of QuickCheck. When your test fails, it gives you a minimised failing test case and a way of reproducing the failure immediately.
MIT License
15 stars 1 forks source link

Trials.reject should be compatible with any type. #68

Open sageserpent-open opened 10 months ago

sageserpent-open commented 10 months ago

Trials.reject currently is typed to yield Unit in Scala and void in Java. This means that it can't be used in a value expression, so it tends to end up either in a guard block or is hoisted right up to a catch clause of a try construct that encloses the entire parameterised test.

It would be nice to make it more like Scala's ??? operator, so it can be used anywhere, safe in the knowledge that it always throw an exception and is thus nominally compatible with any expected type.

Not sure what the equivalent in Java would be - maybe define it as a generic method and hope that type inference will be able to unify at its call sites?

sageserpent-open commented 10 months ago

JUnit5's Assertions.fail uses the generic approach and that seems to work nicely, so that's what we'll do for the Java flavour.