Disabling SWIG in that manner did not work
[Math-GSL.git] / t / Monte.t
blob7d239fa7a03b937f5d48da227f93f7cb2bc62429
1 package Math::GSL::Monte::Test;
2 use Math::GSL::Test qw/:all/;
3 use base q{Test::Class};
4 use Test::More;
5 use Math::GSL::Monte qw/:all/;
6 use Math::GSL::Errno qw/:all/;
7 use Math::GSL::RNG qw/:all/;
8 use Math::GSL qw/:all/;
9 use strict;
11 BEGIN { gsl_set_error_handler_off() }
13 sub make_fixture : Test(setup) {
14     my $self = shift;
15     my $j          = 1 + int(rand(20));
16     $self->{miser} = gsl_monte_miser_alloc($j);
17     $self->{vegas} = gsl_monte_vegas_alloc($j);
18     $self->{plain} = gsl_monte_plain_alloc($j);
19     $self->{dim}   = $j;
22 sub teardown : Test(teardown) {
23     my $self = shift;
24     gsl_monte_miser_free($self->{miser});
25     gsl_monte_plain_free($self->{plain});
26     gsl_monte_vegas_free($self->{vegas});
29 sub TEST_INIT  : Tests {
30     my $self = shift;
31     ok_status( gsl_monte_plain_init($self->{plain}) );
32     ok_status( gsl_monte_vegas_init($self->{vegas}) );
33     ok_status( gsl_monte_miser_init($self->{miser}) );
36 sub TEST_MONTE_VEGAS_INTEGRATE : Tests {
37     my $self = shift;
38     my $state = gsl_monte_vegas_alloc(1);
39     my $rng   = Math::GSL::RNG->new;
40     my $result = [];
41     my $err = [];
42     local $TODO = 'gsl_monte_function is broke';
43     my $status;
44     eval {
45           $status =  gsl_monte_vegas_integrate( sub { $_[0] ** 2 },
46         [ 0 ], [ 1 ], 1, 500_000, $rng->raw, $state, $result, $err)
47     };
48     ok_status($status);
51 sub TEST_ALLOC : Tests {
52     my $self = shift;
53     isa_ok($self->{miser},'Math::GSL::Monte');
54     cmp_ok($self->{miser}->{dim},'==',$self->{dim});
56     isa_ok($self->{vegas},'Math::GSL::Monte');
57     cmp_ok($self->{vegas}->{dim},'==',$self->{dim});
59     isa_ok($self->{plain},'Math::GSL::Monte');
60     cmp_ok($self->{plain}->{dim},'==',$self->{dim});
62 Test::Class->runtests;