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
[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;