NAME

Math::GSL::Test - Assertions and such

SYNOPSIS

use Math::GSL::Test qw/:all/;
ok_similar($x,$y, $msg, $eps);

is_windows()

Returns true if current system is Windows-like.

is_similar($x,$y;$eps,$similarity_function)

is_similar($x,$y);
is_similar($x, $y, 1e-7);
is_similar($x,$y, 1e-3, sub { ... } );

Return true if $x and $y are within $eps of each other, i.e.

abs($x-$y) <= $eps 

If passed a code reference $similarity_function, it will pass $x and $y as parameters to it and will check to see if

$similarity_function->($x,$y_) <= $eps

The default value of $eps is 1e-8. Don't try sending anything to the Moon with this value...

verify( $results, $class)

Takes a hash reference of key/value pairs where the keys are bits of code, which when evaluated should be within some tolerance of the value. For example:

my $results = { 
                'gsl_cdf_ugaussian_P(2.0)'        => [ 0.977250, 1e-5 ],
                'gsl_cdf_ugaussian_Q(2.0)'        => [ 0.022750, 1e-7 ],
                'gsl_cdf_ugaussian_Pinv(0.977250)'=> [ 2.000000 ],
              };
verify($results, 'Math::GSL::CDF');

When no tolerance is given, a value of 1e-8 = 0.00000001 is used. One may use $GSL_NAN and $GSL_INF in comparisons and this routine will use the gsl_isnan() and gsl_isinf() routines to compare them.

Note: Needing to pass in the class name is honky. This may change.

ok_status( $got_status; $expected_status )

ok_status( $status );                  # defaults to checking for $GSL_SUCCESS

ok_status( $status, $GSL_ECONTINUE );

Pass a test if the GSL status codes match, with a default expected status of $GSL_SUCCESS. This function also stringifies the status codes into meaningful messages when it fails.

is_status_ok($status)

is_status_ok( $status );

Return true if $status is $GSL_SUCCESS, false otherwise.

ok_similar( $x, $y, $msg, $eps)

ok_similar( $x, $y);
ok_similar( $x, $y, 'reason');
ok_similar( $x, $y, 'reason', 1e-4);

Pass a test if is_similar($x,$y,$msg,$eps) is true, otherwise fail.

is_similar_relative( $x, $y, $msg, $eps )

is_similar_relative($x, $y, $eps );

Returns true if $x has a relative error with repect to $y less than $eps. The current default for $eps is the same as is_similar(), i.e. 1e-8. This doesn't seem very useful. What should the default be?

ok_similar_relative( $x, $y, $msg, $eps )

ok_similar_relative($x, $y, $msg, $eps );

Pass a test if $x has a relative error with repect to $y less than $eps.