analysis script for upcoming presentation
[scpubgit/stemmatology.git] / t / text_tradition_witness.t
index d2406e7..2457b2c 100644 (file)
@@ -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 = <JSIN>;
-# 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 = <JSIN>;
+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" );
+}
 }