Skip to content

Commit

Permalink
check if lua and Inline::Lua are present, add version numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
rns committed Oct 12, 2014
1 parent 34c1ce7 commit 78c292b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
10 changes: 1 addition & 9 deletions lib/MarpaX/Languages/Lua/AST.pm
Expand Up @@ -13,7 +13,7 @@ $Data::Dumper::Indent = 1;
$Data::Dumper::Terse = 1;
$Data::Dumper::Deepcopy = 1;

use Marpa::R2;
use Marpa::R2 2.096;

# Lua Grammar
# ===========
Expand Down Expand Up @@ -528,17 +528,9 @@ sub fmt{
my ($parser, $ast) = @_;
if (ref $ast){
my ($node_id, @children) = @$ast;
# warn $node_id;
if ($node_id eq 'statements'){
# warn Dumper @children;
warn scalar @children;
warn $children[0]->[0], $children[0]->[1];
warn $children[-1]->[0], $children[-1]->[1];
}
$parser->fmt( $_ ) for @children;
}
else{
# warn $ast;
}
}

Expand Down
7 changes: 7 additions & 0 deletions t/executable_snippets.t
Expand Up @@ -9,6 +9,13 @@ use strict;

use Test::More;

BEGIN {
eval { require Inline::Lua; 1; } or do
{
plan skip_all => "Inline::Lua is not installed";
};
}

use MarpaX::Languages::Lua::AST;

# evaluate snippet: it can be arbitrary, just make sure that
Expand Down
7 changes: 7 additions & 0 deletions t/function.t
Expand Up @@ -13,6 +13,13 @@ use strict;

use Test::More;

BEGIN {
eval { require Inline::Lua; 1; } or do
{
plan skip_all => "Inline::Lua is not installed";
};
}

use MarpaX::Languages::Lua::AST;

my $lua_fact;
Expand Down
22 changes: 22 additions & 0 deletions t/program.t
Expand Up @@ -13,6 +13,27 @@ use strict;

use Test::More;

BEGIN {
my $stderr;
eval
{
my $luav = "lua -v";
# run $luav capturing STDERR (per perlfaq8)
use IPC::Open3;
use File::Spec;
my $in = '';
open(NULL, ">", File::Spec->devnull);
my $pid = open3($in, ">&NULL", \*PH, $luav);
my $stderr = <PH>;
waitpid($pid, 0);
# check lua and its version
$stderr =~ /^Lua 5.1/ims;
} or do
{
plan skip_all => "lua 5.1 not installed or can't be run (lua -v fails)";
};
}

use File::Temp qw{ tempfile };
use Cwd qw();

Expand Down Expand Up @@ -164,3 +185,4 @@ sub whip_up_lua_file{

done_testing();


0 comments on commit 78c292b

Please sign in to comment.