42 lines
684 B
Perl
Executable file
42 lines
684 B
Perl
Executable file
#!/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);
|
|
|
|
die "No tests" unless $plan > 0;
|
|
print "1..$plan\n";
|
|
|
|
exit 0;
|