X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstemma.t;h=8d2fd6edd6af26b950d4c89879047ffa708536eb;hb=b02332cafec34f8fd5af15ff7962a61d512bcf58;hp=6f3e7dbd54fb9106b1af90a0d6a23b40888f3cf5;hpb=68454b71e5a66972515258d6312f6355ee0536f4;p=scpubgit%2Fstemmatology.git diff --git a/t/stemma.t b/t/stemma.t index 6f3e7db..8d2fd6e 100644 --- a/t/stemma.t +++ b/t/stemma.t @@ -5,7 +5,7 @@ use File::Which; use Test::More; use lib 'lib'; use Text::Tradition; -use Text::Tradition::StemmaUtil qw/ phylip_pars_input /; +use Text::Tradition::StemmaUtil qw/ make_character_matrix /; use XML::LibXML; use XML::LibXML::XPathContext; @@ -30,29 +30,23 @@ ok( $stemma->isa( 'Text::Tradition::Stemma' ), 'Got the right sort of object' ); is( $stemma->graph, '1-2,1-A,2-B,2-C', "Got the correct graph" ); # Test for character matrix creation -my $m = phylip_pars_input( $c->make_alignment_table() ); +my $m = make_character_matrix( $c->make_alignment_table() ); ## check number of rows -my $expected = "\t3\t18\n"; -$expected .= 'A AAAAAAAXAAAAAAAAAA -B AXXXAAAAAABABAABAA -C AXXXAAAAABAAAAAXBB'; -$expected .= "\n"; -is( $m, $expected, "Got the right pars input" ); -# is( scalar @$m, 3, "Found three witnesses in char matrix" ); -# ## check number of columns -# is( scalar( @{$m->[0]} ), 19, "Found 18 rows plus sigla in char matrix" ); -# ## check matrix -# my %expected = ( -# 'A' => 'AAAAAAAXAAAAAAAAAA', -# 'B' => 'AXXXAAAAAABABAABAA', -# 'C' => 'AXXXAAAAABAAAAAXBB', -# ); -# my @wits = map { shift @$_; } @$m; -# map { s/\s+//g } @wits; -# foreach my $i ( 0 .. $#wits ) { -# my $w = $wits[$i]; -# is( join( '', @{$m->[$i]} ), $expected{$w}, "Row for witness $w is correct" ); -# } +is( scalar @$m, 3, "Found three witnesses in char matrix" ); + ## check number of columns +is( scalar( @{$m->[0]} ), 19, "Found 18 rows plus sigla in char matrix" ); + ## check matrix +my %expected = ( + 'A' => 'AAAAAAAXAAAAAAAAAA', + 'B' => 'AXXXAAAAAABABAABAA', + 'C' => 'AXXXAAAAABAAAAAXBB', + ); +my @wits = map { shift @$_; } @$m; +map { s/\s+//g } @wits; +foreach my $i ( 0 .. $#wits ) { + my $w = $wits[$i]; + is( join( '', @{$m->[$i]} ), $expected{$w}, "Row for witness $w is correct" ); +} # Test that pars runs SKIP: {