4 use Test::More 'no_plan';
11 use_ok( 'Text::Tradition::Witness', "can use module" );
13 my @text = qw( This is a line of text );
14 my $wit = Text::Tradition::Witness->new(
18 is( ref( $wit ), 'Text::Tradition::Witness', 'Created a witness' );
20 is( $wit->sigil, 'A', "Witness has correct sigil" );
21 is( join( ' ', @{$wit->text} ), join( ' ', @text ), "Witness has correct text" );
31 my @text = qw( This is a line of text );
32 my $wit = Text::Tradition::Witness->new(
35 'identifier' => 'test witness',
37 my $jsonstruct = $wit->export_as_json;
38 is( $jsonstruct->{'id'}, 'A', "got the right witness sigil" );
39 is( $jsonstruct->{'name'}, 'test witness', "got the right identifier" );
40 is( scalar @{$jsonstruct->{'tokens'}}, 6, "got six text tokens" );
41 foreach my $idx ( 0 .. $#text ) {
42 is( $jsonstruct->{'tokens'}->[$idx]->{'t'}, $text[$idx], "tokens look OK" );
45 my @ctext = qw( when april with his showers sweet with fruit the drought of march
46 has pierced unto the root );
47 my $trad = Text::Tradition->new(
48 'input' => 'CollateX',
49 'file' => 't/data/Collatex-16.xml' );
51 $jsonstruct = $trad->witness('A')->export_as_json;
52 is( $jsonstruct->{'id'}, 'A', "got the right witness sigil" );
53 is( $jsonstruct->{'name'}, undef, "got undef for missing identifier" );
54 is( scalar @{$jsonstruct->{'tokens'}}, 17, "got all text tokens" );
55 foreach my $idx ( 0 .. $#ctext ) {
56 is( $jsonstruct->{'tokens'}->[$idx]->{'t'}, $ctext[$idx], "tokens look OK" );