42 lines
651 B
Perl
42 lines
651 B
Perl
|
#!/usr/bin/env perl
|
||
|
|
||
|
use strict;
|
||
|
use warnings;
|
||
|
|
||
|
use FindBin;
|
||
|
|
||
|
use lib "$FindBin::Bin/../lib";
|
||
|
|
||
|
use Minilisp;
|
||
|
|
||
|
my $scriptfile = shift;
|
||
|
|
||
|
die "No script file provided." unless defined $scriptfile && -f $scriptfile;
|
||
|
|
||
|
open(my $fh, "<", $scriptfile) or die "Could not open $scriptfile: $!";
|
||
|
my $script = do { local $/; <$fh> };
|
||
|
close($fh);
|
||
|
|
||
|
# Remove shebang
|
||
|
$script =~ s/^#!.*\n//;
|
||
|
|
||
|
my $parsed = Minilisp::compile($script);
|
||
|
|
||
|
my $plan = 0;
|
||
|
|
||
|
my $ctx = {
|
||
|
'expect' => sub {
|
||
|
my ($desc, $success) = @_;
|
||
|
print "not " unless $success;
|
||
|
print "ok - $desc\n";
|
||
|
$plan++;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
print "TAP Version 13\n";
|
||
|
$parsed->($ctx);
|
||
|
|
||
|
print "1..$plan\n";
|
||
|
|
||
|
exit 0;
|