X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Ftext_tradition.t;h=2c7be1b5afa39b29fcf290a51b8f7f23f82b55d8;hb=62a39b8f5d0ae86b26350664828069a2a44f5645;hp=4c763b9eb3ae6d978f6f624d6bd74c4b87c8296a;hpb=3b853983204d888a90c029c1e66d77b9fa9642b5;p=scpubgit%2Fstemmatology.git diff --git a/t/text_tradition.t b/t/text_tradition.t index 4c763b9..2c7be1b 100644 --- a/t/text_tradition.t +++ b/t/text_tradition.t @@ -25,13 +25,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', 'sourcetype' => 'collation' ); +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 @@ -43,18 +51,18 @@ is( scalar $s->witnesses, 3, "object has three witnesses again" ); { use Text::Tradition; -my $simple = 't/data/simple.txt'; -my $s = Text::Tradition->new( - 'name' => 'inline', +my $t = Text::Tradition->new( + 'name' => 'simple test', 'input' => 'Tabular', - 'file' => $simple, + 'file' => 't/data/simple.txt', ); -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" ); + +is( $t->stemma_count, 0, "No stemmas added yet" ); +my $s; +ok( $s = $t->add_stemma( dotfile => 't/data/simple.dot' ), "Added a simple stemma" ); +is( ref( $s ), 'Text::Tradition::Stemma', "Got a stemma object returned" ); +is( $t->stemma_count, 1, "Tradition claims to have a stemma" ); +is( $t->stemma(0), $s, "Tradition hands back the right stemma" ); }