{
use Text::Tradition;
-my $simple = 't/data/simple.txt';
-my $s = Text::Tradition->new(
- 'name' => 'inline',
- 'input' => 'Tabular',
- 'file' => $simple,
- );
-my $wit_c = $s->witness( 'C' );
-is( ref( $wit_c ), 'Text::Tradition::Witness' ),;
-if( $wit_c ) {
- ok( !$wit_c->has_text, "Text property not yet set" );
- my $c_arr = $wit_c->text;
- is( $c_arr->[0], 'Je', "Text constructed from path" );
- ok( $wit_c->has_text, "Text property now set" );
+my @text = qw( This is a line of text );
+my $wit = Text::Tradition::Witness->new(
+ 'sigil' => 'A',
+ 'text' => \@text,
+ 'identifier' => 'test witness',
+ );
+my $jsonstruct = $wit->export_as_json;
+is( $jsonstruct->{'id'}, 'A', "got the right witness sigil" );
+is( $jsonstruct->{'name'}, 'test witness', "got the right identifier" );
+is( scalar @{$jsonstruct->{'tokens'}}, 6, "got six text tokens" );
+foreach my $idx ( 0 .. $#text ) {
+ is( $jsonstruct->{'tokens'}->[$idx]->{'t'}, $text[$idx], "tokens look OK" );
+}
+
+my @ctext = qw( when april with his showers sweet with fruit the drought of march
+ has pierced unto the root );
+my $trad = Text::Tradition->new(
+ 'input' => 'CollateX',
+ 'file' => 't/data/Collatex-16.xml' );
+
+$jsonstruct = $trad->witness('A')->export_as_json;
+is( $jsonstruct->{'id'}, 'A', "got the right witness sigil" );
+is( $jsonstruct->{'name'}, undef, "got undef for missing identifier" );
+is( scalar @{$jsonstruct->{'tokens'}}, 17, "got all text tokens" );
+foreach my $idx ( 0 .. $#ctext ) {
+ is( $jsonstruct->{'tokens'}->[$idx]->{'t'}, $ctext[$idx], "tokens look OK" );
}
}