Devel-Graph
view release on metacpan or search on metacpan
#!/usr/bin/perl -w
use Test::More;
use Test::Differences;
use strict;
# Parse test snippets from t/data/ and compare them to the stored output
BEGIN
{
chdir 't' if -d 't';
use lib '../lib';
use_ok ("Devel::Graph") or die($@);
};
#############################################################################
# OO interface
my @files;
if (@ARGV)
{
@files = shift;
plan tests => 2;
}
else
{
# get all files to test
opendir(DIR, 'data') or die("Canât opendir 'data': $!");
@files = readdir(DIR);
closedir DIR;
plan tests => 29;
}
my $graph;
my @failures;
for my $file (sort @files)
{
next unless $file =~ /\.txt\z/; # only *.txt
# read in the file
my $FILE;
open ($FILE, "data/$file") or die("Canât read 'data/$file': $!");
my ($code, $line);
my $expect = 'as_ascii';
while (defined ($line = <$FILE>))
{
$expect = $1 if $line =~ /^# EXPECT:\s*(.*)/;
$code = $line unless defined $code;
# print STDERR "read: '$line";
last if $line !~ /^(# |\s+\z)/;
}
$line = '' unless defined $line;
# read the rest in
local $/ = undef; # slurp mode
my $output = $line . <$FILE>; $output = '' unless defined $output;
close $FILE;
$code =~ s/^#\s*//;
# print STDERR "# Testing data/$file:\n";
# print STDERR "# Parsing snippet: $code";
( run in 1.822 second using v1.01-cache-2.11-cpan-39bf76dae61 )