tests all good and it works now... docs mostly done as well
This commit is contained in:
parent
2b2423fc78
commit
79c9f75ae2
|
@ -7,7 +7,7 @@ use File::Temp;
|
|||
|
||||
=head1 NAME
|
||||
|
||||
Math::Giac - The great new Math::Giac!
|
||||
Math::Giac - A perl interface to giac.
|
||||
|
||||
=head1 VERSION
|
||||
|
||||
|
@ -36,6 +36,9 @@ our $VERSION = '0.0.1';
|
|||
$results=$giac->run('mathml(sin(x)+cos(pi)-3)');
|
||||
print $results."\n";
|
||||
|
||||
$giac->set_vars({ A=>2 });
|
||||
my $results=$giac->run('sin(A)+cos(pi)-3');
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 new
|
||||
|
@ -103,7 +106,7 @@ sub run {
|
|||
my @var_list = keys( %{ $self->{vars} } );
|
||||
my $vars_addon = '';
|
||||
foreach my $cur_var (@var_list) {
|
||||
my $vars_addon = $vars_addon . $cur_var . ':=' . $$self->{vars}{$cur_var} . "\n";
|
||||
$vars_addon = $vars_addon . $cur_var . ':=' . $self->{vars}{$cur_var} . "\n";
|
||||
}
|
||||
|
||||
$to_run = $vars_addon . $to_run;
|
||||
|
|
43
t/giac.t
43
t/giac.t
|
@ -13,7 +13,7 @@ BEGIN {
|
|||
my $the_bin = `/bin/sh -c 'which giac 2> /dev/null'`;
|
||||
if ( $? eq 0 ){
|
||||
|
||||
$extra_tests=3;
|
||||
$extra_tests=7;
|
||||
|
||||
my $worked=0;
|
||||
my $giac;
|
||||
|
@ -21,7 +21,7 @@ if ( $? eq 0 ){
|
|||
$giac=Math::Giac->new;
|
||||
$worked=1;
|
||||
};
|
||||
ok( $worked eq '1', 'init check') or diag('failed to init the module');
|
||||
ok( $worked eq '1', 'init check') or diag('failed to init the module... '.$@);
|
||||
|
||||
# basic single line return test
|
||||
my $returned='';
|
||||
|
@ -44,6 +44,45 @@ if ( $? eq 0 ){
|
|||
$extra_error='... '.$@;
|
||||
}
|
||||
ok( $returned =~ /MathML/, 'run check') or diag('"mathml(sin(pi))" returned "'.$returned.'" and does not match /MathML/'.$extra_error);
|
||||
|
||||
# make sure that we can set the variables
|
||||
$worked=1;
|
||||
eval{
|
||||
$giac->vars_set({A=>2});
|
||||
$worked=1;
|
||||
};
|
||||
ok( $worked eq '1', 'vars_set') or diag('Calling vars_set failed... '.$@);
|
||||
|
||||
# run a test using a variable
|
||||
$returned='';
|
||||
$extra_error='';
|
||||
eval{
|
||||
$returned=$giac->run("3+A");
|
||||
};
|
||||
if ( $@ ){
|
||||
$extra_error='... '.$@;
|
||||
}
|
||||
ok( $returned eq '5', 'variable test') or diag('"3+A" where A=2 returned "'.$returned.'" instead of "5"'.$extra_error);
|
||||
|
||||
# make sure that we can clear
|
||||
$worked=1;
|
||||
eval{
|
||||
$giac->vars_clear;
|
||||
$worked=1;
|
||||
};
|
||||
ok( $worked eq '1', 'vars_clear') or diag('Calling vars_clear failed... '.$@);
|
||||
|
||||
# run a test using a variable post clearing the vars
|
||||
$returned='';
|
||||
$extra_error='';
|
||||
eval{
|
||||
$returned=$giac->run("3+A");
|
||||
};
|
||||
if ( $@ ){
|
||||
$extra_error='... '.$@;
|
||||
}
|
||||
ok( $returned eq '3+A', 'variable test 2') or diag('"3+A" where A=undef returned "'.$returned.'" instead of "3+A"'.$extra_error);
|
||||
|
||||
}
|
||||
|
||||
my $tests_ran=1+$extra_tests;
|
||||
|
|
Loading…
Reference in New Issue