Graph-Easy
view release on metacpan or search on metacpan
* Graph: use CSS child selectors to shorten classnames (and remove
class='fill' or class='' from output)
* Graph: as_html(): fix IDs on labels, lines etc
* Graph: fix layout code for edges with labels: no longer needs position:
relative, allows better copy&paste and is not garbled on scrolling
* syntax.pl: support custom template name
* simplifiy and generalize t/simple.t
* always run test files under -w
* don't use warnings (for older perls)
* remove needless routines in subclasses of "Node"
* use Test::Differences if t/ascii.t fails
2005-01-31 v0.11 Tels 294 tests - Close, close, close, close the ugly holes...
* Parser: add parsing of groups like in "( Groupname [ Node ] )"
* Parser: fix for "[1] -> [2] -> [3] { ... }" to not lose attributes on 3
* Parser: can now handle "[1], [2], [3] -> [4]" correctly
* Parser: cut out rendundant parsing code
* Graph: add group(), add_group(), del_group(), groups()
* Graph: fix css(): 'link', 'label' and 'title' do not need to appear in CSS
* Graph: suppress default attributes from groups, too
* Graph: close "holes" in "arrows" (edges) with line-height & letter-spacing
my $parser = Graph::Easy::Parser->new( debug => 0);
is (ref($parser), 'Graph::Easy::Parser');
is ($parser->error(), '', 'no error yet');
opendir DIR, "t/in" or die ("Cannot read dir 'in': $!");
my @files = readdir(DIR); closedir(DIR);
my @failures;
eval { require Test::Differences; };
binmode (STDERR, ':utf8') or die ("Cannot do binmode(':utf8') on STDERR: $!");
binmode (STDOUT, ':utf8') or die ("Cannot do binmode(':utf8') on STDOUT: $!");
foreach my $f (sort @files)
{
my $path = "t/in/$f";
next unless -f $path; # only files
next unless $f =~ /\.txt/; # ignore anything else
# print "should: $out\n";
if (!
is ($ascii, $out, "from $f"))
{
if ($ENV{__SHLOMIF__UPDATE_ME})
{
_write_utf8_file($out_path, $ascii);
}
push @failures, $f;
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($ascii, $out);
}
else
{
fail ("Test::Differences not installed");
}
}
my $txt_path = "t/txt/$f";
# if the txt output differes, read it in
if (-f $txt_path)
{
$txt = readfile($txt_path);
}
# else
# }
if (!
is ($graph->as_txt(), $txt, "$f as_txt"))
{
if ($ENV{__SHLOMIF__UPDATE_ME})
{
_write_utf8_file($txt_path, scalar( $graph->as_txt() ));
}
push @failures, $f;
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($graph->as_txt(), $txt);
}
else
{
fail ("Test::Differences not installed");
}
}
# print a debug output
my $debug = $ascii;
$debug =~ s/\n/\n# /g;
print "# Generated:\n#\n# $debug\n";
}
if (@failures)
is ($def_parser->error(), '', 'no error yet');
my $dir = File::Spec->catdir('in','gdl');
opendir DIR, $dir or die ("Cannot read dir $dir: $!");
my @files = readdir(DIR); closedir(DIR);
binmode (STDERR, ':utf8') or die ("Cannot do binmode(':utf8') on STDERR: $!");
binmode (STDOUT, ':utf8') or die ("Cannot do binmode(':utf8') on STDOUT: $!");
eval { require Test::Differences; };
foreach my $f (sort {
$a =~ /^(\d+)/; my $a1 = $1 || '1';
$b =~ /^(\d+)/; my $b1 = $1 || '1';
$a1 <=> $b1 || $a cmp $b;
} @files)
{
my $file = File::Spec->catfile($dir,$f);
my $parser = $def_parser;
$out =~ s/(^|\n)#[^# ]{2}.*\n//g; # remove comments
$out =~ s/\n\n\z/\n/mg; # remove empty lines
# print "txt: $txt\n";
# print "ascii: $ascii\n";
# print "should: $out\n";
if (!
is ($ascii, $out, "from $f"))
{
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($ascii, $out);
}
else
{
fail ("Test::Differences not installed");
}
}
# if the txt output differes, read it in
my $f_txt = File::Spec->catfile('txt','gdl',$of);
if (-f $f_txt)
{
$txt = readfile($f_txt);
}
$graph->debug(1);
if (!
is ($graph->as_txt(), $txt, "$f as_txt"))
{
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($graph->as_txt(), $txt);
}
else
{
fail ("Test::Differences not installed");
}
}
# print a debug output
my $debug = $ascii;
$debug =~ s/\n/\n# /g;
print "# Generated:\n#\n# $debug\n";
}
1;
t/graphml.t view on Meta::CPAN
<graphml xmlns="http://graphml.graphdrawing.org/xmlns"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd">
EOR
. $result unless $result =~ /<\?xml/;
if (!is ($graphml, $result, $name))
{
eval { require Test::Differences; };
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($result, $graphml);
}
}
}
t/graphml_yed.t view on Meta::CPAN
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:y="http://www.yworks.com/xml/graphml"
xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
http://www.yworks.com/xml/schema/graphml/1.0/ygraphml.xsd">
EOR
. $result unless $result =~ /<\?xml/;
if (!is ($result, $graphml, $name))
{
eval { require Test::Differences; };
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($result, $graphml);
}
}
}
opendir DIR, $dir or die ("Cannot read dir '$dir': $!");
my @files = readdir(DIR); closedir(DIR);
opendir DIR, 'dot' or die ("Cannot read dir 'dot': $!");
push @files, readdir(DIR); closedir(DIR);
binmode (STDERR, ':utf8') or die ("Cannot do binmode(':utf8') on STDERR: $!");
binmode (STDOUT, ':utf8') or die ("Cannot do binmode(':utf8') on STDOUT: $!");
eval { require Test::Differences; };
foreach my $f (sort {
$a =~ /^(\d+)/; my $a1 = $1 || '1';
$b =~ /^(\d+)/; my $b1 = $1 || '1';
$a1 <=> $b1 || $a cmp $b;
} @files)
{
my $file = File::Spec->catfile($dir,$f);
my $parser = $def_parser;
if (!-f $file)
# print "ascii: $ascii\n";
# print "should: $out\n";
if (!
is ($ascii, $out, "from $f"))
{
if ($ENV{__SHLOMIF__UPDATE_ME})
{
_write_utf8_file($out_path, $ascii);
}
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($ascii, $out);
}
else
{
fail ("Test::Differences not installed");
}
}
# if the txt output differes, read it in
my $f_txt = File::Spec->catfile('txt','dot',$of);
if (-f $f_txt)
{
$txt = readfile($f_txt);
}
$graph->debug(1);
if (!
is ($graph->as_txt(), $txt, "$f as_txt"))
{
if ($ENV{__SHLOMIF__UPDATE_ME})
{
_write_utf8_file($f_txt, scalar( $graph->as_txt() ));
}
if (defined $Test::Differences::VERSION)
{
Test::Differences::eq_or_diff ($graph->as_txt(), $txt);
}
else
{
fail ("Test::Differences not installed");
}
}
# print a debug output
my $debug = $ascii;
$debug =~ s/\n/\n# /g;
print "# Generated:\n#\n# $debug\n";
}
# check that only the expected warnings were generated
( run in 2.490 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )