Commit | Line | Data |
64a36834 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | use Test::More 'no_plan'; |
5 | $| = 1; |
6 | |
7 | |
8 | |
9 | # =begin testing |
10 | { |
64a36834 |
11 | use TryCatch; |
12 | |
13 | use_ok( 'Text::Tradition::Stemma' ); |
14 | |
64a36834 |
15 | # Try to create a bad graph |
ea45d2a6 |
16 | TODO: { |
17 | local $TODO = "cannot use stdout redirection trick with FastCGI"; |
64a36834 |
18 | my $baddotfh; |
ea45d2a6 |
19 | open( $baddotfh, 't/data/besoin_bad.dot' ) or die "Could not open test dotfile"; |
20 | try { |
21 | my $stemma = Text::Tradition::Stemma->new( dot => $baddotfh ); |
22 | ok( 0, "Created broken stemma from dotfile with syntax error" ); |
23 | } catch( Text::Tradition::Error $e ) { |
24 | like( $e->message, qr/^Error trying to parse/, "Syntax error in dot threw exception" ); |
25 | } |
64a36834 |
26 | } |
27 | |
28 | # Create a good graph |
29 | my $dotfh; |
30 | open( $dotfh, 't/data/florilegium.dot' ) or die "Could not open test dotfile"; |
31 | binmode( $dotfh, ':utf8' ); |
ace5fce5 |
32 | my $stemma = Text::Tradition::Stemma->new( dot => $dotfh ); |
64a36834 |
33 | is( ref( $stemma ), 'Text::Tradition::Stemma', "Created stemma from good dotfile" ); |
34 | is( scalar $stemma->witnesses, 13, "Found correct number of extant witnesses" ); |
35 | is( scalar $stemma->hypotheticals, 8, "Found correct number of extant hypotheticals" ); |
36 | my $found_unicode_sigil; |
37 | foreach my $h ( $stemma->hypotheticals ) { |
38 | $found_unicode_sigil = 1 if $h eq "\x{3b1}"; |
39 | } |
40 | ok( $found_unicode_sigil, "Found a correctly encoded Unicode sigil" ); |
ea45d2a6 |
41 | |
42 | # TODO Create stemma from graph, create stemma from undirected graph, |
43 | # create stemma from incompletely-specified graph |
64a36834 |
44 | } |
45 | |
46 | |
47 | |
48 | |
49 | 1; |