#########################
###use Data::Dumper ; print Dumper( $XML->tree ) ;
use ExtUtils::MakeMaker qw(prompt) ;
use strict qw(vars) ;
use Test;
BEGIN { plan tests => 162 } ;
use XML::Smart ;
no warnings ;
my $DATA = q`
192.168.0.1
192.168.0.2
192.168.1.10
192.168.1.20
`;
##if (0) {
#########################
{
my $XML = XML::Smart->new( q`
Blah blah
` );
my $data = $XML->data( noheader => 1 ) ;
$data =~ s/\s+/ /gs ;
ok($data , q` Blah blah `) ;
my @order = $XML->{html}{body}{form}->order ;
ok(join(" ", @order) eq 'input br input br') ;
$XML->{html}{body}{form}->set_order( qw(br input input br) ) ;
@order = $XML->{html}{body}{form}->order ;
ok(join(" ", @order) eq 'br input input br') ;
my $data = $XML->data( noheader => 1 ) ;
$data =~ s/\s+/ /gs ;
ok($data , q` Blah blah `) ;
}
#########################
{
my $XML = XML::Smart->new(q`
content0
sub_content
content1
content2
` , 'XML::Smart::Parser') ;
my $data = $XML->data(noheader => 1) ;
ok($data , q`
content0
sub_content
content1
content2
`) ;
ok( tied $XML->{root}->pointer->{CONTENT} ) ;
my $cont = $XML->{root}->{CONTENT} ;
ok($cont , q`
content0
content1
content2
`) ;
my $cont_ = $XML->{root}->content ;
ok($cont_ , q`
content0
content1
content2
`) ;
$XML->{root}->content(1,"set1") ;
my @cont = $XML->{root}->content ;
ok($cont[0] , "\ncontent0\n") ;
ok($cont[1] , "set1") ;
ok($cont[2] , "\ncontent2\n") ;
$XML->{root}->{CONTENT} = 123 ;
my $cont_2 = $XML->{root}->content ;
skip( ($] >= 5.007 && $] <= 5.008 ? "Skip on $]" : 0 ) , $cont_2 , 123) ;
skip( ($] >= 5.007 && $] <= 5.008 ? "Skip on $]" : 0 ) , !tied $XML->{root}->pointer->{CONTENT} ) ;
ok( !tied $XML->{root}{tag1}{sub}->pointer->{CONTENT} ) ;
my $sub_cont = $XML->{root}{tag1}{sub}->{CONTENT} ;
ok($sub_cont , 'sub_content') ;
my $data = $XML->data(noheader => 1) ;
skip( ($] >= 5.007 && $] <= 5.008 ? "Skip on $]" : 0 ) ,
$data , q`123
sub_content
`) ;
}
#########################
{
my $xml = new XML::Smart(q`
aaa
bbb
`) ;
$xml = $xml->{root} ;
$xml->{phone}->content('XXX') ;
$xml->{phone}[1]->content('YYY') ;
$xml->{test}->content('ZZZ') ;
my $data = $xml->data(noheader => 1) ;
ok($data , q`
XXX
YYY
ZZZ
`) ;
}
#########################
{
my $xml = new XML::Smart(q`
TEXT1 & more
aaa
bbb
`,'html') ;
my $data = $xml->data(noident=>1 , noheader => 1 , wild=>1) ;
ok($data,q`
TEXT1 & more
aaa
bbb
`) ;
}
#########################
{
my $XML = XML::Smart->new('text1foobartext2' , 'XML::Smart::Parser') ;
my $data = $XML->data(noheader => 1) ;
$data =~ s/\s//g ;
ok($data,'text1foobartext2') ;
}
#########################
{
my $XML = XML::Smart->new('' , 'XML::Smart::Parser') ;
my $data = $XML->data(noheader => 1) ;
$data =~ s/\s//gs ;
ok($data,'') ;
}
#########################
{
my $XML = XML::Smart->new($DATA , 'XML::Smart::Parser') ;
my $data = $XML->data(nometagen => 1) ;
$data =~ s/\s//gs ;
my $data_org = $DATA ;
$data_org =~ s/\s//gs ;
ok($data,$data_org) ;
}
#########################
{
my $XML = XML::Smart->new('' , 'XML::Smart::HTMLParser') ;
my $data = $XML->data(noheader => 1) ;
$data =~ s/\s//gs ;
ok($data,'') ;
my $XML = XML::Smart->new(q`
TITLE
end" w=q>
FOO2-DATA
` , 'HTML') ;
my $data = $XML->data(noheader => 1 , nospace => 1 ) ;
ok($data,q`TITLEFOO2-DATA`) ;
my $XML = XML::Smart->new(q`
TITLE
` , 'HTML') ;
my $data = $XML->data(noheader => 1 , nospace => 1) ;
$data =~ s/\s//gs ;
ok($data,q`TITLE