From: Tara L Andrews Date: Tue, 6 Mar 2012 13:34:35 +0000 (+0100) Subject: more robust boolean value checking in tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=adc08836a8f9e1bff3b372c498ac1dcda1100894;p=scpubgit%2Fstemmatology.git more robust boolean value checking in tests --- diff --git a/lib/Text/Tradition/Analysis.pm b/lib/Text/Tradition/Analysis.pm index bf4c938..8dcf25d 100644 --- a/lib/Text/Tradition/Analysis.pm +++ b/lib/Text/Tradition/Analysis.pm @@ -107,7 +107,8 @@ foreach my $row ( @{$data->{'variants'}} ) { unless( exists $expected_genealogical{$row->{'id'}} ) { $expected_genealogical{$row->{'id'}} = 1; } - is( $row->{'genealogical'}, $expected_genealogical{$row->{'id'}}, + my $gen_bool = $row->{'genealogical'} ? 1 : 0; + is( $gen_bool, $expected_genealogical{$row->{'id'}}, "Got correct genealogical flag for row " . $row->{'id'} ); } is( $data->{'variant_count'}, 58, "Got right total variant number" ); diff --git a/t/analysis.t b/t/analysis.t index 2388d91..d22a91b 100755 --- a/t/analysis.t +++ b/t/analysis.t @@ -17,6 +17,9 @@ my $tradition = Text::Tradition->new( 'file' => 't/data/besoin.xml' ); $tradition->add_stemma( 'dotfile' => 't/data/besoin.dot' ); +# Hack to avoid warning +$tradition->collation->add_relationship( '493,2', '493,3', {'type'=>'orthographic'} ); + # Run the analysis of the tradition my $results = run_analysis( $tradition ); @@ -118,7 +121,8 @@ foreach my $row ( @{$results->{'variants'}} ) { unless( exists $expected{$row->{'id'}} ) { $expected{$row->{'id'}} = 1; } - is( $row->{'genealogical'}, $expected{$row->{'id'}}, + my $gen_bool = $row->{'genealogical'} ? 1 : ''; + is( $gen_bool, $expected{$row->{'id'}}, "Got expected genealogical result for rank " . $row->{'id'} ); # If the row is genealogical, there should be one reading with no parents, # every reading should independently occur exactly once, and the total diff --git a/t/text_tradition_analysis.t b/t/text_tradition_analysis.t index 74428ef..8340d4c 100644 --- a/t/text_tradition_analysis.t +++ b/t/text_tradition_analysis.t @@ -55,7 +55,8 @@ foreach my $row ( @{$data->{'variants'}} ) { unless( exists $expected_genealogical{$row->{'id'}} ) { $expected_genealogical{$row->{'id'}} = 1; } - is( $row->{'genealogical'}, $expected_genealogical{$row->{'id'}}, + my $gen_bool = $row->{'genealogical'} ? 1 : 0; + is( $gen_bool, $expected_genealogical{$row->{'id'}}, "Got correct genealogical flag for row " . $row->{'id'} ); } is( $data->{'variant_count'}, 58, "Got right total variant number" );