From: tla Date: Fri, 25 Oct 2013 14:14:13 +0000 (+0200) Subject: make TEI-PS parser package variables safe for multiple invocations. Fixes #10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f08498a5d4fa2d83a79cf138b796ae68696242dc;p=scpubgit%2Fstemmatology.git make TEI-PS parser package variables safe for multiple invocations. Fixes #10 --- diff --git a/base/lib/Text/Tradition/Parser/TEI.pm b/base/lib/Text/Tradition/Parser/TEI.pm index 3b0649f..85e9f64 100644 --- a/base/lib/Text/Tradition/Parser/TEI.pm +++ b/base/lib/Text/Tradition/Parser/TEI.pm @@ -67,6 +67,17 @@ if( $t ) { is( scalar $t->collation->paths, 361, "Collation has all paths" ); } +# Try to re-parse it, ensure we can use the parser twice in the same Perl +# invocation + +my $t2 = Text::Tradition->new( + 'name' => 'inline', + 'input' => 'TEI', + 'file' => $par_seg, + ); + +is( ref( $t2 ), 'Text::Tradition', "Parsed parallel-segmentation TEI again" ); + =end testing =cut @@ -81,10 +92,11 @@ my $app_count; # Keep track of how many apps we have # Would really like to do this with varname variables, but apparently this # is considered a bad idea. The long way round then. -my( $LISTWIT, $WITNESS, $TEXT, $W, $SEG, $APP, $RDG, $LEM ) - = ( 'listWit', 'witness', 'text', 'w', 'seg', 'app', 'rdg', 'lem' ); +my( $LISTWIT, $WITNESS, $TEXT, $W, $SEG, $APP, $RDG, $LEM ); sub _make_tagnames { my( $ns ) = @_; + ( $LISTWIT, $WITNESS, $TEXT, $W, $SEG, $APP, $RDG, $LEM ) + = ( 'listWit', 'witness', 'text', 'w', 'seg', 'app', 'rdg', 'lem' ); if( $ns ) { $LISTWIT = "$ns:$LISTWIT"; $WITNESS = "$ns:$WITNESS"; diff --git a/base/t/text_tradition_parser_tei.t b/base/t/text_tradition_parser_tei.t index 2fb33a8..7ae1f8f 100644 --- a/base/t/text_tradition_parser_tei.t +++ b/base/t/text_tradition_parser_tei.t @@ -25,6 +25,17 @@ if( $t ) { is( scalar $t->collation->readings, 311, "Collation has all readings" ); is( scalar $t->collation->paths, 361, "Collation has all paths" ); } + +# Try to re-parse it, ensure we can use the parser twice in the same Perl +# invocation + +my $t2 = Text::Tradition->new( + 'name' => 'inline', + 'input' => 'TEI', + 'file' => $par_seg, + ); + +is( ref( $t2 ), 'Text::Tradition', "Parsed parallel-segmentation TEI again" ); }