Update META.yml
[Math-GSL.git] / lib / Math / GSL / Deriv / Test.pm
blobf5f808cd7caf363d5727884b84776473a0b66b1c
1 package Math::GSL::Deriv::Test;
2 use Math::GSL::Test qw/:all/;
3 use base 'Test::Class';
4 use Test::More 'no_plan';
5 use Math::GSL qw/:all/;
6 use Math::GSL::Deriv qw/:all/;
7 use Math::GSL::Errno qw/:all/;
8 use Test::Exception;
9 use Data::Dumper;
10 use strict;
11 use warnings;
13 BEGIN{ gsl_set_error_handler_off() };
15 sub make_fixture : Test(setup) {
16 my $self = shift;
17 $self->{gsl_func} = Math::GSL::Deriv::gsl_function_struct->new;
20 sub teardown : Test(teardown) {
23 sub TEST_FUNCTION_STRUCT : Tests {
24 my $self = shift;
26 isa_ok( $self->{gsl_func},'Math::GSL::Deriv::gsl_function_struct');
29 sub TEST_DERIV_CENTRAL_DIES : Tests {
30 my ($x,$h)=(10,0.01);
31 throws_ok( sub {
32 gsl_deriv_central( 'IAMNOTACODEREF', $x, $h);
33 },qr/not a reference value/, 'gsl_deriv_central borks when first arg is not a coderef');
36 sub AAA_TEST_DERIV_CENTRAL : Tests {
37 my ($status, $result, $abserr);
38 my ($x,$h)=(10,0.01);
39 my $self = shift;
40 my @other;
43 ($status, $result, $abserr, @other) = gsl_deriv_central (
44 sub { my $x=shift;
45 print "IN ANON SUB in perl\n";
46 print Dumper [$x] ;
47 return $x ** 3
49 $x, $h,
50 # $result, $abserr
51 );
52 warn Dumper [ $status , $result, $abserr, \@other ];
54 ok_status($status);
55 local $TODO = 'return value is not correct';
56 ok_similar( [$result], [3*$x], 'gsl_deriv_central returns correct value for anon sub' );
59 sub TEST_DERIV_CENTRAL_CALLS_THE_SUB : Tests {
60 my ($status, $result, $abserr);
61 my ($x,$h)=(10,0.01);
62 my $self = shift;
64 throws_ok( sub {
65 gsl_deriv_central ( sub { die "CALL ME BACK!"} , $x, $h)
66 }, qr/CALL ME BACK/, 'gsl_deriv_central can call anon sub' );