Subject: | Another test case |
A test case for the non-halting condition would be nice. Here's one, which probably only works on Unix systems (maybe also on systems with pseudo-forking).
Regards,
Slaven
#!/usr/bin/perl
use strict;
use Test::More; plan tests => 1;
use Acme::HaltingProblem;
{
local $TODO = "This code does not correctly deal with the case where the machine does not halt.";
pipe(READER,WRITER);
alarm(3);
$SIG{ALRM} = sub { die }; # just terminate the read
if (fork == 0) {
close READER;
my $problem = new Acme::HaltingProblem(
Machine => sub { while (1) { sleep 1 } },
Input => [ "any" ],
);
print WRITER $problem->analyse, "\n";
exit 0;
}
close WRITER;
my $analyse = eval { <READER> };
chomp $analyse if defined $analyse;
ok($analyse, "The machine does not halt.");
}