fix Tabular parser to account for a.c. wits; more doc and tests
[scpubgit/stemmatology.git] / t / text_tradition.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use Test::More 'no_plan';
5 $| = 1;
6
7
8
9 # =begin testing
10 {
11 use_ok( 'Text::Tradition', "can use module" );
12
13 my $t = Text::Tradition->new( 'name' => 'empty' );
14 is( ref( $t ), 'Text::Tradition', "initialized an empty Tradition object" );
15 is( $t->name, 'empty', "object has the right name" );
16 is( scalar $t->witnesses, 0, "object has no witnesses" );
17
18 my $simple = 't/data/simple.txt';
19 my $s = Text::Tradition->new( 
20     'name'  => 'inline', 
21     'input' => 'Tabular',
22     'file'  => $simple,
23     );
24 is( ref( $s ), 'Text::Tradition', "initialized a Tradition object" );
25 is( $s->name, 'inline', "object has the right name" );
26 is( scalar $s->witnesses, 3, "object has three witnesses" );
27
28 my $w = $s->add_witness( 'sigil' => 'D' );
29 is( ref( $w ), 'Text::Tradition::Witness', "new witness created" );
30 is( $w->sigil, 'D', "witness has correct sigil" );
31 is( scalar $s->witnesses, 4, "object now has four witnesses" );
32
33 my $del = $s->del_witness( 'D' );
34 is( $del, $w, "Deleted correct witness" );
35 is( scalar $s->witnesses, 3, "object has three witnesses again" );
36
37 # TODO test initialization by witness list when we have it
38 }
39
40
41
42 # =begin testing
43 {
44 use Text::Tradition;
45
46 my $simple = 't/data/simple.txt';
47 my $s = Text::Tradition->new( 
48     'name'  => 'inline', 
49     'input' => 'Tabular',
50     'file'  => $simple,
51     );
52 my $wit_a = $s->witness('A');
53 is( ref( $wit_a ), 'Text::Tradition::Witness', "Found a witness A" );
54 if( $wit_a ) {
55     is( $wit_a->sigil, 'A', "Witness A has the right sigil" );
56 }
57 is( $s->witness('X'), undef, "There is no witness X" );
58 }
59
60
61
62
63 1;