~ubuntu-branches/debian/jessie/libxml-twig-perl/jessie

« back to all changes in this revision

Viewing changes to t/test_additional.t

  • Committer: Package Import Robot
  • Author(s): Bart Martens
  • Date: 2014-01-05 22:58:27 UTC
  • mfrom: (1.3.5)
  • Revision ID: package-import@ubuntu.com-20140105225827-k8vqp9bffrupmdj5
Tags: 1:3.44-1
* New upstream release.  Closes: #720457, #721395, #694523.
* debian/control: Updated Homepage.  Closes: #720616.
* debian/patches/series: Added.  Enables patches.
* debian/patches/07_691028.diff: Added.  Closes: #691028.

Show diffs side-by-side

added added

removed removed

Lines of Context:
819
819
 
820
820
# more tests on subs_text
821
821
822
 
my $doc='<doc><p>link to http://www.xmltwig.com but do not link to http://bad.com, though link to toto and link to http://www.xml.com</p><p>now http://www.nolink.com and do not link to this and do not link to http://www.bad.com and do not link to http://www.bad2.com and link to http://link.com also</p></doc>';
823
 
my $expected='<doc><p>see <a href="http://www.xmltwig.com">www.xmltwig.com</a> but do not link to http://bad.com, though link to toto and see <a href="http://www.xml.com">www.xml.com</a></p><p>now http://www.nolink.com and do not link to this and do not link to http://www.bad.com and do not link to http://www.bad2.com and see <a href="http://link.com">link.com</a> also</p></doc>';
 
822
my $doc='<doc><p>link to http://www.xmltwig.org but do not link to http://bad.com, though link to toto and link to http://www.xml.com</p><p>now http://www.nolink.com and do not link to this and do not link to http://www.bad.com and do not link to http://www.bad2.com and link to http://link.com also</p></doc>';
 
823
my $expected='<doc><p>see <a href="http://www.xmltwig.org">www.xmltwig.org</a> but do not link to http://bad.com, though link to toto and see <a href="http://www.xml.com">www.xml.com</a></p><p>now http://www.nolink.com and do not link to this and do not link to http://www.bad.com and do not link to http://www.bad2.com and see <a href="http://link.com">link.com</a> also</p></doc>';
824
824
my $t= XML::Twig->new->parse( $doc);
825
825
my $got= $t->subs_text( qr{(?<!do not )link to (http://(\S+[\w/]))}, 'see &elt( a =>{ href => $1 }, $2)');
826
826
is( $got->sprint, $expected, 'complex substitution with subs_text');# test 284
1265
1265
      $t->root->toSAX1( $writer);
1266
1266
      is( normalize_xml( $writer->end_document), $doc, 'root toSAX1');# test 360
1267
1267
 
1268
 
      my $doc_flush="<doc><p>p 1</p><add/><p/><p>text<flush/> more text</p></doc>";
1269
 
      my $doc_flushed=qq{<?xml version="1.0" encoding="UTF-8"?><doc><p>p 1</p><add/><g>a</g><p/><p>text<flush/> more text</p></doc>};
 
1268
      my $doc_flush='<!DOCTYPE doc [<!ENTITY foo "bar">]><doc><p>p 1</p><add/><p/><p>text<flush/> more text &foo; </p></doc>';
 
1269
      my $doc_flushed=qq{<?xml version="1.0" encoding="UTF-8"?><doc><p>p 1</p><add/><g>a</g><p/><p>text<flush/> more text bar </p></doc>};
1270
1270
      $writer = XML::Handler::YAWriter->new( AsString => 1, Pretty => { CatchEmptyElement => 1 });
1271
1271
      $writer->start_document;
1272
1272