File: u_cd_rv.t

package info (click to toggle)
libgraph-perl 1%3A0.9726-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 996 kB
  • sloc: perl: 4,083; sh: 8; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 680 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use Graph;
use strict; use warnings;
use Test::More tests => 2;

package MyNode;
use overload ('""' => '_asstring', fallback=>1);
sub new {
    my ($class, %ops) = @_;
    return bless { %ops }, $class;
}
sub _asstring {
    my ($self) = @_;
    my $str = $self->{'name'};
    return $self->{'name'};
}
1;

package main;
use strict; use warnings;
my $gnoref = new Graph;
my $gwithref = new Graph(refvertexed_stringified=>1);
ok $gwithref->refvertexed_stringified;
my $n1 = new MyNode('name'=>'alpha');
my $n2 = new MyNode('name'=>'beta');
$gnoref->add_edge($n1, $n2);
$gwithref->add_edge($n1, $n2);

is_deeply([sort keys %{$gnoref->[2]->[4]}],[sort keys %{$gwithref->[2]->[4]}]);