remove some debugging statements
[scpubgit/stemmatology.git] / t / text_tradition_parser_json.t
CommitLineData
a731e73a 1#!/usr/bin/perl -w
2
3use strict;
4use Test::More 'no_plan';
5$| = 1;
6
7
8
9# =begin testing
10{
11use Text::Tradition;
12binmode STDOUT, ":utf8";
13binmode STDERR, ":utf8";
14eval { no warnings; binmode $DB::OUT, ":utf8"; };
15
16use_ok( 'Text::Tradition::Parser::JSON' );
17
18open( JSFILE, 't/data/cx16.json' );
19binmode JSFILE, ':utf8';
20my @lines = <JSFILE>;
21close JSFILE;
22
23my $t = Text::Tradition->new(
24 'name' => 'json',
25 'input' => 'JSON',
26 'string' => join( '', @lines ),
27);
28
29is( ref( $t ), 'Text::Tradition', "Parsed a JSON alignment" );
30if( $t ) {
31 is( scalar $t->collation->readings, 26, "Collation has all readings" );
32 is( scalar $t->collation->paths, 32, "Collation has all paths" );
33 is( scalar $t->witnesses, 3, "Collation has all witnesses" );
34}
b0b4421a 35
36my %seen_wits;
37map { $seen_wits{$_} = 0 } qw/ A B C /;
38# Check that we have the right witnesses
39foreach my $wit ( $t->witnesses ) {
40 $seen_wits{$wit->sigil} = 1;
41}
42is( scalar keys %seen_wits, 3, "No extra witnesses were made" );
43foreach my $k ( keys %seen_wits ) {
44 ok( $seen_wits{$k}, "Witness $k still exists" );
45}
46
47# Check that the witnesses have the right texts
48foreach my $wit ( $t->witnesses ) {
49 my $origtext = join( ' ', @{$wit->text} );
50 my $graphtext = $t->collation->path_text( $wit->sigil );
51 is( $graphtext, $origtext, "Collation matches original for witness " . $wit->sigil );
52}
a731e73a 53}
54
55
56
57
581;