Minilisp.pm/tool/test-runner.pl

39 lines
623 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;
my $parsed = Minilisp::compile_file($scriptfile);
my $plan = 0;
my $ctx = {
'expect' => sub {
my ($desc, $success) = @_;
print "not " unless $success;
print "ok - $desc\n";
$plan++;
},
comment => sub {
my ($v) = @_;
print "# " . Minilisp::lisp_format($v) . "\n";
},
};
print "TAP Version 13\n";
$parsed->($ctx);
die "No tests" unless $plan > 0;
print "1..$plan\n";
exit 0;