---
name: "Math::GSL::Test"
section: "3pm"
platform: "linux"
package: "libmath-gsl-perl"
version: "0.45-2+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Math::GSL::Test"
---

# Math::GSL::Test(3pm)

Assertions and such

## 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 respect 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 respect to `$y` less than `$eps`.
