10 unshift @INC, '../lib'; # for running manually
14 # test whether Math::BigInt->config() and Math::BigFloat->config() works
19 my $mbi = 'Math::BigInt'; my $mbf = 'Math::BigFloat';
21 ##############################################################################
24 ok ($mbi->can('config'));
26 my $cfg = $mbi->config();
28 ok (ref($cfg),'HASH');
30 ok ($cfg->{lib},'Math::BigInt::Calc');
31 ok ($cfg->{lib_version}, $Math::BigInt::Calc::VERSION);
32 ok ($cfg->{class},$mbi);
33 ok ($cfg->{upgrade}||'','');
34 ok ($cfg->{div_scale},40);
36 ok ($cfg->{precision}||0,0); # should test for undef
37 ok ($cfg->{accuracy}||0,0);
39 ok ($cfg->{round_mode},'even');
41 ok ($cfg->{trap_nan},0);
42 ok ($cfg->{trap_inf},0);
44 ##############################################################################
47 ok ($mbf->can('config'));
49 $cfg = $mbf->config();
51 ok (ref($cfg),'HASH');
53 ok ($cfg->{lib},'Math::BigInt::Calc');
54 ok ($cfg->{with},'Math::BigInt::Calc');
55 ok ($cfg->{lib_version}, $Math::BigInt::Calc::VERSION);
56 ok ($cfg->{class},$mbf);
57 ok ($cfg->{upgrade}||'','');
58 ok ($cfg->{div_scale},40);
60 ok ($cfg->{precision}||0,0); # should test for undef
61 ok ($cfg->{accuracy}||0,0);
63 ok ($cfg->{round_mode},'even');
65 ok ($cfg->{trap_nan},0);
66 ok ($cfg->{trap_inf},0);
68 ##############################################################################
78 upgrade => 'Math::BigInt::SomeClass',
79 downgrade => 'Math::BigInt::SomeClass',
84 foreach my $key (keys %$test)
86 # see if setting in MBI works
87 eval ( "$mbi\->config( $key => '$test->{$key}' );" );
88 $c = $mbi->config(); ok ("$key = $c->{$key}", "$key = $test->{$key}");
90 # see if setting it in MBI leaves MBF alone
91 if (($c->{$key}||0) ne $test->{$key})
97 ok ("$key eq $c->{$key}","$key ne $test->{$key}");
100 # see if setting in MBF works
101 eval ( "$mbf\->config( $key => '$test->{$key}' );" );
102 $c = $mbf->config(); ok ("$key = $c->{$key}", "$key = $test->{$key}");
105 ##############################################################################
106 # test setting illegal keys (should croak)
108 my $never_reached = 0;
109 eval ("$mbi\->config( 'some_garbage' => 1 ); $never_reached = 1;");
110 ok ($never_reached,0);
113 eval ("$mbf\->config( 'some_garbage' => 1 ); $never_reached = 1;");
114 ok ($never_reached,0);
116 # this does not work. Why?
117 #ok (@!, "Illegal keys 'some_garbage' passed to Math::BigInt->config() at ./config.t line 104");