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