wollok icon indicating copy to clipboard operation
wollok copied to clipboard

Shouldn't throwsExceptionWithType take superclasses in consideration?

Open mmatos opened this issue 7 years ago • 0 comments

Given the following exceptions:

class NoSePuedeAgregar inherits Exception{} class NoCumpleSerCompositor inherits NoSePuedeAgregar{} class NoCumpleHabilidad inherits NoSePuedeAgregar{}

And this assertion: assert.throwsExceptionWithType(new NoSePuedeAgregar(), {presentacion1.agregarMusico(kike)})

I would have expected that if the block shown in the assertion fails due to an NoCumpleSerCompositor, the assertion would still pass since it is also of type NoSePuedeAgregar, so if you don't really care which was the specific cause you can still use an assertion that is not as generic as throwsException, following the same logic as a try/catch.

Is there a reason not to consider supertypes here?

mmatos avatar Nov 19 '17 22:11 mmatos