commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Phil Steitz <phil.ste...@gmail.com>
Subject Re: [Math] Exceptions from "JDKRandomGenerator"
Date Sat, 19 Dec 2015 18:35:26 GMT
On 12/19/15 9:02 AM, Gilles wrote:
> Hi.
>
> While experimenting on
>   https://issues.apache.org/jira/browse/MATH-1300
> I created a new
>   JDKRandomGeneratorTest
> that inherits from
>   RandomGeneratorAbstractTest
> similarly to the classes for testing all the other RNG implemented
> in CM.
>
> The following tests (implemented in the base class) failed:
> 1.
> testNextIntNeg(org.apache.commons.math4.random.JDKRandomGeneratorTest) 
> Time elapsed: 0.001 sec  <<< ERROR!
>    java.lang.Exception: Unexpected exception,
> expected<org.apache.commons.math4.exception.MathIllegalArgumentException>
> but was<java.lang.IllegalArgumentException>
> 2.
> testNextIntIAE2(org.apache.commons.math4.random.JDKRandomGeneratorTest) 
> Time elapsed: 0.015 sec  <<< ERROR!
>    java.lang.IllegalArgumentException: bound must be positive
>
> This is caused by try/catch clauses that expect a
> "MathIllegalArgumentException"
> but "JDKRandomGenerator" extends "java.util.Random" that for those
> methods throws
> "IllegalArgumentException".
>
> What to do?

I would change the test to expect IllegalArgumentException.  Most
[math] generators actually throw NotStrictlyPositiveException here,
which extends MIAE, which extends IAE, so this should work.

Phil
>
>
> Regards,
> Gilles
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message