X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition_witness.t;h=2457b2c548c146e98363cdbbafdff36de9da02c3;hb=HEAD;hp=d2406e7900db4d835fe7e16707c5dd541c5022e8;hpb=fae52efdaeb4b67f58e47ec8ebe110537f2535ea;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition_witness.t b/t/text_tradition_witness.t index d2406e7..2457b2c 100644 --- a/t/text_tradition_witness.t +++ b/t/text_tradition_witness.t @@ -25,29 +25,40 @@ if( $ptwit ) { is( $c->path_text( $ptwit->sigil ), $str, "Witness has correct text" ); } -# # Test some JSON witnesses via object -# open( JSIN, 't/data/witnesses/testwit.json' ) or die "Could not open JSON test input"; -# binmode( JSIN, ':encoding(UTF-8)' ); -# my @lines = ; -# close JSIN; -# $trad->add_json_witnesses( join( '', @lines ) ); -# is( ref( $trad->witness( 'MsAJ' ) ), 'Text::Tradition::Witness', -# "Found first JSON witness" ); -# is( ref( $trad->witness( 'MsBJ' ) ), 'Text::Tradition::Witness', -# "Found second JSON witness" ); -# -# # Test an XML witness via file -# my $xmlwit = $trad->add_witness( 'sourcetype' => 'xmldesc', -# 'file' => 't/data/witnesses/teiwit.xml' ); -# is( ref( $xmlwit ), 'Text::Tradition::Witness', "Created witness from XML file" ); -# if( $xmlwit ) { -# is( $xmlwit->sigil, 'V887', "XML witness has correct sigil" ); -# ok( $xmlwit->is_layered, "Picked up correction layer" ); -# is( @{$xmlwit->path}, 185, "Got correct text length" ); -# is( @{$xmlwit->uncorrected_path}, 185, "Got correct a.c. text length" ); -# } +# Test some JSON witnesses via object +open( JSIN, 't/data/witnesses/testwit.json' ) or die "Could not open JSON test input"; +binmode( JSIN, ':encoding(UTF-8)' ); +my @lines = ; +close JSIN; +$trad->add_json_witnesses( join( '', @lines ) ); +is( ref( $trad->witness( 'MsAJ' ) ), 'Text::Tradition::Witness', + "Found first JSON witness" ); +is( ref( $trad->witness( 'MsBJ' ) ), 'Text::Tradition::Witness', + "Found second JSON witness" ); + +# Test an XML witness via file +my $xmlwit = $trad->add_witness( 'sourcetype' => 'xmldesc', + 'file' => 't/data/witnesses/teiwit.xml' ); +is( ref( $xmlwit ), 'Text::Tradition::Witness', "Created witness from XML file" ); +if( $xmlwit ) { + is( $xmlwit->sigil, 'V887', "XML witness has correct sigil" ); + ok( $xmlwit->is_layered, "Picked up correction layer" ); + is( @{$xmlwit->text}, 182, "Got correct text length" ); + is( @{$xmlwit->layertext}, 182, "Got correct a.c. text length" ); +} +my @allwitwords = grep { $_->id =~ /^V887/ } $c->readings; +is( @allwitwords, 184, "Reused appropriate readings" ); ## Test use_text +my $xpwit = $trad->add_witness( 'sourcetype' => 'xmldesc', + 'file' => 't/data/witnesses/group.xml', + 'use_text' => '//tei:group/tei:text[2]' ); +is( ref( $xpwit ), 'Text::Tradition::Witness', "Created witness from XML group" ); +if( $xpwit ) { + is( $xpwit->sigil, 'G', "XML part witness has correct sigil" ); + ok( !$xpwit->is_layered, "Picked up no correction layer" ); + is( @{$xpwit->text}, 157, "Got correct text length" ); +} }