X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FText%2FTradition.pm;h=e10198d126461e9b9264071ca5e46c0eb4537782;hb=3a2ebbf4607bc7ab83788e5a57c44a960829cd1c;hp=14b22533a2c50486d34d3a651fac36ad02662b9b;hpb=3b853983204d888a90c029c1e66d77b9fa9642b5;p=scpubgit%2Fstemmatology.git diff --git a/lib/Text/Tradition.pm b/lib/Text/Tradition.pm index 14b2253..e10198d 100644 --- a/lib/Text/Tradition.pm +++ b/lib/Text/Tradition.pm @@ -157,11 +157,21 @@ Witness objects. Return the Text::Tradition::Witness objects associated with this tradition, as an array. +=head2 B( $sigil ) + +Returns the Text::Tradition::Witness object whose sigil is $sigil, or undef +if there is no such object within the tradition. + =head2 B( %opts ) Instantiate a new witness with the given options (see documentation for Text::Tradition::Witness) and add it to the tradition. +=head2 B( $sigil ) + +Delete the witness with the given sigil from the tradition. Returns the +witness object for the deleted witness. + =begin testing use_ok( 'Text::Tradition', "can use module" ); @@ -181,13 +191,21 @@ is( ref( $s ), 'Text::Tradition', "initialized a Tradition object" ); is( $s->name, 'inline', "object has the right name" ); is( scalar $s->witnesses, 3, "object has three witnesses" ); -my $w = $s->add_witness( 'sigil' => 'D' ); -is( ref( $w ), 'Text::Tradition::Witness', "new witness created" ); -is( $w->sigil, 'D', "witness has correct sigil" ); +my $wit_a = $s->witness('A'); +is( ref( $wit_a ), 'Text::Tradition::Witness', "Found a witness A" ); +if( $wit_a ) { + is( $wit_a->sigil, 'A', "Witness A has the right sigil" ); +} +is( $s->witness('X'), undef, "There is no witness X" ); +ok( !exists $s->{'witnesses'}->{'X'}, "Witness key X not created" ); + +my $wit_d = $s->add_witness( 'sigil' => 'D' ); +is( ref( $wit_d ), 'Text::Tradition::Witness', "new witness created" ); +is( $wit_d->sigil, 'D', "witness has correct sigil" ); is( scalar $s->witnesses, 4, "object now has four witnesses" ); my $del = $s->del_witness( 'D' ); -is( $del, $w, "Deleted correct witness" ); +is( $del, $wit_d, "Deleted correct witness" ); is( scalar $s->witnesses, 3, "object has three witnesses again" ); # TODO test initialization by witness list when we have it @@ -228,7 +246,7 @@ sub BUILD { $self->_save_collation( $collation ); # Call the appropriate parser on the given data - my @format_standalone = qw/ Self CollateX CTE TEI Tabular /; + my @format_standalone = qw/ Self CollateText CollateX CTE TEI Tabular /; my @format_basetext = qw/ KUL /; my $use_base; my $format = $init_args->{'input'}; @@ -258,32 +276,6 @@ sub BUILD { } } -=head2 B( $sigil ) - -Returns the Text::Tradition::Witness object whose sigil is $sigil, or undef -if there is no such object within the tradition. - -=begin testing - -use Text::Tradition; - -my $simple = 't/data/simple.txt'; -my $s = Text::Tradition->new( - 'name' => 'inline', - 'input' => 'Tabular', - 'file' => $simple, - ); -my $wit_a = $s->witness('A'); -is( ref( $wit_a ), 'Text::Tradition::Witness', "Found a witness A" ); -if( $wit_a ) { - is( $wit_a->sigil, 'A', "Witness A has the right sigil" ); -} -is( $s->witness('X'), undef, "There is no witness X" ); - -=end testing - -=cut - no Moose; __PACKAGE__->meta->make_immutable;