]> git.donarmstrong.com Git - deb_pkgs/libstatistics-r-perl.git/blobdiff - t/03-run.t
New upstream version 0.34
[deb_pkgs/libstatistics-r-perl.git] / t / 03-run.t
index cf3ea5adcb24f1417b5deee81190a0e4d398dfb8..a8889ab2b13c1d01f05e1e431d0c7e8b85df1a6d 100644 (file)
@@ -3,27 +3,37 @@
 use strict;
 use warnings;
 use Test::More;
+use File::Copy;
+use File::Temp;
 use Statistics::R;
+use File::Spec::Functions;
 
-plan tests => 15;
-
-
-my ($R, $expected);
+my ($R, $expected, $bin, $version);
 
 my $file = 'file.ps';
 
 ok $R = Statistics::R->new();
 
-ok $R->bin() =~ /\S+/, 'Binary';
+ok $bin = $R->bin();
+ok $bin =~ /\S+/, 'Executable name';
 
 $expected = '';
 is $R->run( ), $expected;
 
+ok $bin = $R->bin();
+ok $bin =~ /\S+/, 'Executable path';
+
+ok $version = $R->version();
+ok $version =~ /^\d+\.\d+\.\d+$/, 'Version';
+
+diag "R version $version found at $bin\n";
+
+
 $expected = '';
 is $R->run( qq`postscript("$file" , horizontal=FALSE , width=500 , height=500 , pointsize=1)`), $expected, 'Basic';
 
 $expected = '';
-is $R->run( q`plot(c(1, 5, 10), type = "l")` ), $expected;
+is $R->run( q`plot(c(1, 5, 10), type = "l");` ), $expected;
 
 $expected = 
 'null device 
@@ -76,5 +86,11 @@ Some innocuous message on stdout
 [1] 123
 456
 [1] "ok"';
-is $R->run_from_file( './t/data/script.R' ), $expected, 'Commands from file';
+$file = catfile('t', 'data', 'script.R');
+is $R->run_from_file( $file ), $expected, 'Command from file (relative path)';
+
+my $absfile = File::Temp->new( UNLINK => 1 )->filename;
+copy($file, $absfile) or die "Error: Could not copy file $file to $absfile: $!\n";
+is $R->run_from_file( $absfile ), $expected, 'Commands from file (absolute path)';
 
+done_testing;