Hi,

On 24.03.2015 00:15, Tom Browder wrote:
> On Mon, Mar 23, 2015 at 5:53 PM, Elizabeth Mattijsen <l...@dijkmat.nl> wrote:
>>> On 23 Mar 2015, at 23:50, Tom Browder <tom.brow...@gmail.com> wrote:
>>> Question:  Would it be better to submit pull requests for some (or
>>> all) for the rakudo Test module or start creating a new Test::*
>>> module?
>> Good question.
>> What functionality are you currently missing in Test.pm ??
> 
> From CPAN Test::Number::Delta:
> 
> # Equality test with default tolerance
> delta_ok( 1e-5, 2e-5, 'values within 1e-6');
> 
> # Provide specific tolerance
> delta_within( 1e-3, 2e-3, 1e-4, 'values within 1e-4');
> 
> # Compare arrays or matrices
> @a = ( 3.14, 1.41 );
> @b = ( 3.15, 1.41 );
> delta_ok( \@a, \@b, 'compare @a and @b' );
> 
> # Set a different default tolerance
> use Test::Number::Delta within => 1e-5;
> delta_ok( 1.1e-5, 2e-5, 'values within 1e-5'); # ok
> 
> # Set a relative tolerance
> use Test::Number::Delta relative => 1e-3;
> delta_ok( 1.01, 1.0099, 'values within 1.01e-3');
> 
> Note that the functions can be used for scalars or suitable arrays
> (and they each have a 'not' version for convenience).
> 
> So far I've used the core's 'is_approx' for the 'delta_ok' emulation,
> but 'is_approx' doesn't allow the user to specify tolerances as
> 'delta_ok' does.  The ability to specify tolerances would be useful
> for the core 'is_approx' function.

I'd suggest developing those test functions in a separate module, and
after gathering some experience with it, when can discuss putting them
into rakudo's Test.pm.

Cheers,
Moritz

Reply via email to