|
From: Petr P. <pa...@us...> - 2003-03-16 16:21:32
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext/t
In directory sc8-pr-cvs1:/tmp/cvs-serv27568/t
Modified Files:
00-xpathcontext.t
Log Message:
- added getContextNode and setContextNode
- XPathContext object now increments PmmREFCNT for ctx->node and ctx->doc
Index: 00-xpathcontext.t
===================================================================
RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/00-xpathcontext.t,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- 00-xpathcontext.t 14 Mar 2003 14:32:04 -0000 1.1.1.1
+++ 00-xpathcontext.t 16 Mar 2003 16:21:28 -0000 1.2
@@ -1,5 +1,5 @@
use Test;
-BEGIN { plan tests => 11 };
+BEGIN { plan tests => 15 };
use XML::LibXML;
use XML::LibXML::XPathContext;
@@ -38,3 +38,17 @@
my $xc = XML::LibXML::XPathContext->new($doc1);
$xc->registerNs('xxx', 'http://example.com/foobar');
ok($xc->findnodes('/xxx:foo')->pop->nodeName eq 'foo');
+
+# test getContextNode and setContextNode
+ok($xc->getContextNode->isSameNode($doc1));
+$xc->setContextNode($doc1->getDocumentElement);
+ok($xc->getContextNode->isSameNode($doc1->getDocumentElement));
+ok($xc->findnodes('.')->pop->isSameNode($doc1->getDocumentElement));
+
+# test xpath context preserves the document
+my $xc2=XML::LibXML::XPathContext->new(
+ XML::LibXML->new->parse_string(<<'XML'));
+<foo/>
+XML
+ok($xc2->findnodes('*')->pop->nodeName eq 'foo');
+
|