Minilisp.pm/tool/test-runner.pl
2021-04-09 00:01:27 +02:00

43 lines
737 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 $expected_plan;
my $ctx = {
'expect' => sub {
my ($desc, $success) = @_;
print "not " unless $success;
print "ok - $desc\n";
},
comment => sub {
my ($v) = @_;
print "# " . Minilisp::lisp_format($v) . "\n";
},
plan => sub {
die "Multiple plans" if defined $expected_plan;
$expected_plan = shift;
}
};
print "TAP Version 13\n";
$parsed->($ctx);
die "No plan" unless defined $expected_plan;
print "1..$expected_plan\n";
exit 0;