4 use Test::More 'no_plan';
13 use_ok( 'Text::Tradition::Stemma' );
15 # Try to create a bad graph
17 my $stemma = Text::Tradition::Stemma->new( dotfile => 't/data/besoin_bad.dot' );
18 ok( 0, "Created broken stemma from dotfile with syntax error" );
19 } catch( Text::Tradition::Error $e ) {
20 like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" );
24 my $stemma = Text::Tradition::Stemma->new( dotfile => 't/data/florilegium.dot' );
25 is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" );
26 is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" );
27 is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" );
28 ok( $stemma->has_identifier, "Stemma identifier was found in dot" );
29 is( $stemma->identifier, 'Coislinianum lineage', "Correct stemma identifier was found in dot" );
30 my $found_unicode_sigil;
31 foreach my $h ( $stemma->hypotheticals ) {
32 $found_unicode_sigil = 1 if $h eq "\x{3b1}";
34 ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" );
36 # Create an undirected graph
37 my $udstemma = Text::Tradition::Stemma->new( dotfile => 't/data/besoin_undirected.dot' );
38 is( ref( $udstemma ), 'Text::Tradition::Stemma', "Created stemma from undirected dotfile" );
39 is( scalar $udstemma->witnesses, 13, "Found correct number of extant witnesses" );
40 is( scalar $udstemma->hypotheticals, 12, "Found correct number of hypotheticals" );
41 ok( $udstemma->is_undirected, "Stemma was recorded as undirected" );
42 is( $udstemma->identifier, "RHM stemma", "Undirected graph retained its name" );