PATH=/usr/bin:/bin:/Users/fly2400/cpanfly-5.24/var/megalib/bin
Start 2018-12-05T02:00:47
ActivePerl-2400 CPAN-2.10
Reading '/Users/fly2400/cpanfly-5.24/var/cpan/Metadata'
Database was generated on Tue, 04 Dec 2018 06:54:28 GMT
Checksum for /Users/fly2400/cpanfly-5.24/var/cpan/sources/authors/id/P/PR/PRBRENAN/Data-Edit-Xml-20181204.tar.gz ok
Data-Edit-Xml-20181204
Data-Edit-Xml-20181204/Build.PL
Data-Edit-Xml-20181204/MANIFEST
Data-Edit-Xml-20181204/META.json
Data-Edit-Xml-20181204/META.yml
Data-Edit-Xml-20181204/test.pl
Data-Edit-Xml-20181204/lib
Data-Edit-Xml-20181204/lib/Data
Data-Edit-Xml-20181204/lib/Data/Edit
Data-Edit-Xml-20181204/lib/Data/Edit/Xml.pm
Configuring P/PR/PRBRENAN/Data-Edit-Xml-20181204.tar.gz with Build.PL
>>> /Users/fly2400/ap2400-300558/bin/perl-dynamic Build.PL
Checking prerequisites...
requires:
! Data::Table::Text (20180724) is installed, but we need version >= 20181204
ERRORS/WARNINGS FOUND IN PREREQUISITES. You may wish to install the versions
of the modules indicated above before proceeding with this installation
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Data-Edit-Xml' version '20181204'
PRBRENAN/Data-Edit-Xml-20181204.tar.gz
/Users/fly2400/ap2400-300558/bin/perl-dynamic Build.PL -- OK
Running Build for P/PR/PRBRENAN/Data-Edit-Xml-20181204.tar.gz
---- Unsatisfied dependencies detected during ----
---- PRBRENAN/Data-Edit-Xml-20181204.tar.gz ----
Data::Table::Text [requires]
Running test for module 'Data::Table::Text'
Checksum for /Users/fly2400/cpanfly-5.24/var/cpan/sources/authors/id/P/PR/PRBRENAN/Data-Table-Text-20181204.tar.gz ok
Data-Table-Text-20181204
Data-Table-Text-20181204/Build.PL
Data-Table-Text-20181204/MANIFEST
Data-Table-Text-20181204/META.json
Data-Table-Text-20181204/META.yml
Data-Table-Text-20181204/test.pl
Data-Table-Text-20181204/lib
Data-Table-Text-20181204/lib/Data
Data-Table-Text-20181204/lib/Data/Table
Data-Table-Text-20181204/lib/Data/Table/Text.pm
Configuring P/PR/PRBRENAN/Data-Table-Text-20181204.tar.gz with Build.PL
>>> /Users/fly2400/ap2400-300558/bin/perl-dynamic Build.PL
Created MYMETA.yml and MYMETA.json
Creating new 'Build' script for 'Data-Table-Text' version '20181204'
PRBRENAN/Data-Table-Text-20181204.tar.gz
/Users/fly2400/ap2400-300558/bin/perl-dynamic Build.PL -- OK
Running Build for P/PR/PRBRENAN/Data-Table-Text-20181204.tar.gz
>>> ./Build
Building Data-Table-Text
PRBRENAN/Data-Table-Text-20181204.tar.gz
./Build -- OK
Running Build test
>>> ./Build test verbose=1
# Failed test at (eval 21) line 739.
# Structures begin differing at:
# $got->[1] = '/tmp/MUp6QtGJCy//ddd/'
# $expected->[1] = '/tmp/MUp6QtGJCy/ddd/'
# Looks like you failed 1 test of 462.
test.pl ..
1..462
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
ok 21
ok 22
ok 23
ok 24
ok 25
ok 26
ok 27
ok 28
ok 29
ok 30
ok 31
ok 32
ok 33
ok 34
ok 35
ok 36
ok 37
ok 38
ok 39
ok 40
ok 41
ok 42
ok 43
ok 44
ok 45
ok 46
ok 47
ok 48
ok 49
ok 50
ok 51
ok 52
ok 53
ok 54
ok 55
ok 56
ok 57
ok 58
ok 59
ok 60
ok 61
ok 62
ok 63
ok 64
ok 65
ok 66
ok 67
ok 68
ok 69
ok 70
ok 71
ok 72
ok 73
ok 74
ok 75
ok 76
ok 77
ok 78
ok 79
ok 80
ok 81
ok 82
ok 83
ok 84
ok 85
ok 86
ok 87
ok 88
ok 89
ok 90
ok 91
ok 92
ok 93
ok 94
ok 95
ok 96
ok 97
ok 98
ok 99
ok 100
ok 101
ok 102
ok 103
ok 104
ok 105
ok 106
ok 107
ok 108
ok 109
ok 110
ok 111
ok 112
ok 113
ok 114
ok 115
ok 116
ok 117
ok 118
ok 119
ok 120
ok 121
ok 122
ok 123
ok 124
ok 125
ok 126
ok 127
ok 128
ok 129
ok 130 # skip Takes too much time
ok 131 # skip Takes too much time
ok 132 # skip Takes too much time
ok 133 # skip Takes too much time
ok 134 # skip Takes too much time
ok 135 # skip Takes too much time
ok 136 # skip Takes too much time
ok 137 # skip Takes too much time
ok 138 # skip Takes too much time
ok 139 # skip Takes too much time
ok 140 # skip Takes too much time
ok 141
ok 142
ok 143
ok 144
ok 145
ok 146
ok 147
ok 148
ok 149
ok 150
ok 151
ok 152
ok 153
ok 154
ok 155
ok 156
ok 157
ok 158
ok 159
ok 160
ok 161
ok 162
ok 163
ok 164
ok 165
ok 166
ok 167
ok 168
ok 169
ok 170
ok 171
ok 172
ok 173
ok 174
ok 175
ok 176
ok 177
ok 178
ok 179
ok 180
ok 181
ok 182
ok 183
ok 184
ok 185
ok 186
ok 187
ok 188
ok 189
ok 190
ok 191
ok 192
ok 193
ok 194
ok 195
ok 196
ok 197
ok 198
ok 199
ok 200
ok 201
ok 202
ok 203
ok 204
ok 205
ok 206
ok 207
ok 208
ok 209
ok 210
ok 211
ok 212
ok 213
ok 214
ok 215
ok 216
ok 217
ok 218
ok 219
ok 220
ok 221
ok 222
ok 223
ok 224
ok 225
ok 226
ok 227
ok 228
ok 229
ok 230
ok 231
ok 232
ok 233
ok 234
ok 235
ok 236
ok 237
ok 238
ok 239
ok 240
ok 241
ok 242
ok 243
ok 244
ok 245
ok 246
ok 247
ok 248
ok 249
ok 250
ok 251
ok 252
ok 253
ok 254
ok 255
ok 256
ok 257
ok 258
ok 259
ok 260
ok 261
ok 262
ok 263
ok 264
ok 265
ok 266
ok 267
ok 268
ok 269
ok 270
ok 271
ok 272
ok 273
ok 274
ok 275
ok 276
ok 277
ok 278
ok 279
ok 280
ok 281
ok 282
ok 283
ok 284
ok 285
ok 286
ok 287
ok 288
ok 289
ok 290
ok 291
not ok 292
ok 293
ok 294
ok 295
ok 296
ok 297
ok 298
ok 299
ok 300
ok 301
ok 302
ok 303
ok 304
ok 305
ok 306
ok 307
ok 308
ok 309
ok 310
ok 311
ok 312
ok 313
ok 314
ok 315
ok 316
ok 317
ok 318
ok 319 -
ok 320
ok 321
ok 322
ok 323
ok 324
ok 325
ok 326
ok 327
ok 328
ok 329
ok 330
ok 331
ok 332
ok 333
ok 334
ok 335
ok 336
ok 337
ok 338
ok 339
ok 340
ok 341
ok 342
ok 343
ok 344
ok 345
ok 346
ok 347
ok 348
ok 349
ok 350
ok 351
ok 352
ok 353
ok 354
ok 355
ok 356
ok 357
ok 358
ok 359
ok 360
ok 361
ok 362
ok 363
ok 364
ok 365
ok 366
ok 367
ok 368
ok 369
ok 370
ok 371
ok 372
ok 373
ok 374
ok 375
ok 376
ok 377
ok 378
ok 379
ok 380
ok 381
ok 382
ok 383
ok 384
ok 385
ok 386
ok 387
ok 388
ok 389
ok 390
ok 391
ok 392
ok 393
ok 394
ok 395
ok 396
ok 397
ok 398
ok 399
ok 400
ok 401
ok 402
ok 403
ok 404
ok 405
ok 406
ok 407
ok 408
ok 409
ok 410
ok 411
ok 412
ok 413
ok 414
ok 415
ok 416
ok 417
ok 418
ok 419
ok 420
ok 421
ok 422
ok 423
ok 424
ok 425
ok 426
ok 427
ok 428
ok 429
ok 430
ok 431
ok 432
ok 433
ok 434
ok 435
ok 436
ok 437
ok 438
ok 439
ok 440
ok 441
ok 442
ok 443
ok 444
ok 445
ok 446
ok 447
ok 448
ok 449
ok 450
ok 451
ok 452
ok 453
ok 454
ok 455
ok 456
ok 457
ok 458
ok 459
ok 460
ok 461
ok 462
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/462 subtests
(less 11 skipped subtests: 450 okay)
Test Summary Report
-------------------
test.pl (Wstat: 256 Tests: 462 Failed: 1)
Failed test: 292
Non-zero exit status: 1
Files=1, Tests=462, 2 wallclock secs ( 0.04 usr 0.01 sys + 0.80 cusr 0.89 csys = 1.74 CPU)
Result: FAIL
Failed 1/1 test programs. 1/462 subtests failed.
PRBRENAN/Data-Table-Text-20181204.tar.gz
./Build test verbose=1 -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports PRBRENAN/Data-Table-Text-20181204.tar.gz
PRBRENAN/Data-Edit-Xml-20181204.tar.gz
Has already been unwrapped into directory /Users/fly2400/cpanfly-5.24/var/tmp/cpan_build/Data-Edit-Xml-20181204-QmSzBR
PRBRENAN/Data-Edit-Xml-20181204.tar.gz
Has already been prepared
Running Build for P/PR/PRBRENAN/Data-Edit-Xml-20181204.tar.gz
Warning: Prerequisite 'Data::Table::Text => 20181204' for 'PRBRENAN/Data-Edit-Xml-20181204.tar.gz' failed when processing 'PRBRENAN/Data-Table-Text-20181204.tar.gz' with 'make_test => NO'. Continuing, but chances to succeed are limited.
>>> ./Build
Building Data-Edit-Xml
PRBRENAN/Data-Edit-Xml-20181204.tar.gz
./Build -- OK
Running Build test
>>> ./Build test verbose=1
No such method : Data::Edit::Xml::overWriteFile at lib/Data/Edit/Xml.pm line 4338, line 5084.
Data::Edit::Xml::AUTOLOAD("/tmp/0qV6D8lH21", " ") called at (eval 119) line 566
eval 'use warnings FATAL=>qw(all);
use strict;
use Test::More tests=>1018;
use Data::Table::Text qw(:all);
my $windows = $^O =~ m(MSWin32)is;
my $mac = $^O =~ m(darwin)is;
Test::More->builder->output("/dev/null") # Show only errors during testing
if ((caller(1))[0]//\'Data::Edit::Xml\') eq "Data::Edit::Xml";
sub sample1{my $x = Data::Edit::Xml::new(); $x->input = <parse} # Sample test XML
Hello
there
Howdy
do
doo
HHHHello
to you
END
if (1)
{my $x = Data::Edit::Xml::new; #Tparse
$x->inputString = <
END
$x->parse; #Tparse
ok -p $x eq <
END
}
sub sample2
{my $x = Data::Edit::Xml::new; #TinputString
$x->inputString = <
END
$x->parse; #TinputString
}
if (1) # Parse and string
{my $x = sample1;
if (my $s = $x->string)
{ok $s eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
# ok nn($x->prettyString) eq \'N HelloN N thereN N N HowdyN N N NdoNdooN N HHHHelloN N to youN N N N N N N NN\';
ok nn($x->stringContent) eq \'HelloN thereHowdyN doNdooN HHHHelloN to you\';
ok $x->attr(qq(start)) eq "yes";
$x->id = 11;
ok $x->id == 11;
$x->deleteAttr(qq(id));
ok !$x->id;
ok join(\' \', $x->go(qw(head))->attrs(qw(id start))) eq "a 123";
# ok nn($x->prettyStringContent) eq \'HelloN N thereN NNHowdyN N NNdoNdooN NHHHHelloN N to youN NNN N N NN\';
ok $x->countTags == 17;
ok $x->go(qw(head 1))->countTags == 4;
}
if (1) # Conditions
{my $m = $x->go(qw(tail middle));
$m->addConditions(qw(middle MIDDLE)); # Add
ok join(\' \', $m->listConditions) eq \'MIDDLE middle\'; # List
$m->deleteConditions(qw(MIDDLE)); # Remove
ok join(\'\', $m->listConditions) eq \'middle\';
$_->addConditions(qw(foot)) for $x->go(qw(tail foot *));
ok $x->stringWithConditions(qw(middle)) eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
ok $x->stringWithConditions(qw(foot)) eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
ok $x->stringWithConditions(qw(none)) eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
ok $x->stringWithConditions(qw(foot middle)) eq $x->string;
ok $x->stringWithConditions eq $x->string;
}
if (my $h = $x->go(qw(head))) {ok $h->id eq q(a)} else {ok 0} # Attributes and sub nodes
# Contents
is_deeply [map {$_->tag} $x->contents] , [qw(head bar CDATA head tail)];
is_deeply [map {$_->tag} $x->go(qw(head)) ->contentAfter], [qw(bar CDATA head tail)];
is_deeply [map {$_->tag} $x->go(qw(head), 1)->contentBefore], [qw(head bar CDATA)];
ok $x->contentAsTags eq join \' \', qw(head bar CDATA head tail);
ok $x->go(qw(head),0)->contentAfterAsTags eq join \' \', qw( bar CDATA head tail);
ok $x->go(qw(head),1)->contentBeforeAsTags eq join \' \', qw(head bar CDATA);
ok $x->over(qr(\\Ahead bar CDATA head tail\\Z));
ok $x->go(qw(head),0)->matchAfter (qr(\\Abar CDATA head tail\\Z));
ok $x->go(qw(head),1)->matchBefore(qr(\\Ahead bar CDATA\\Z));
ok $x->c(qw(head)) == 2;
ok $x->go(qw(tail))->present(qw(foot middle aaa bbb)) == 2; # Presence of the specified tags
ok $x->go(qw(tail))->present(qw(foot aaa bbb)) == 1;
ok $x->go(qw(tail))->present(qw( aaa bbb)) == 0;
ok $x->go(qw(tail foot))->present(qw(aaa bbb)) == 0;
if (1)
{my $c = $x->count(qw(head tail aaa));
ok $c == 3;
my @c = $x->count(qw(head tail aaa));
ok "@c" eq "2 1 0";
my $t = $x->count(qw(CDATA));
ok $t == 1;
my $T = $x->count;
ok $T == 5;
}
if (1) # First child
{ok $x->go(qw(tail))->firstIn(qw(foot middle))->id == 11;
ok $x->go(qw(tail))-> lastIn(qw(feet middle))->id eq qq(mm);
}
ok $x->go(qw(head *)) == 2;
ok $x->go(qw(head),1)->position == 3;
ok $x->go(qw(tail))->first->id == 11;
ok $x->go(qw(tail))->last ->id == 22;
ok $x->go(qw(tail))->first->isFirst;
ok $x->go(qw(tail))->last ->isLast;
ok !$x->go(qw(tail))->last->isOnlyChild;
ok $x->go(qw(tail))->first->next->id eq \'mm\';
ok $x->go(qw(tail))->last->prev->prev->isFirst;
ok $x->go(qw(head))->go(qw(em))->first->at(qw(CDATA em head foo)); # At
if (1) # Through
{my @t;
$x->first->by(sub {my ($o) = @_; push @t, $o->tag});
is_deeply [@t], [qw(CDATA CDATA em head)];
}
if (1)
{my @t;
$x->last->by(sub {my ($o) = @_; push @t, $o->tag});
is_deeply [@t], [qw(foot middle foot tail)];
}
# Editing - outermost - wrapWith
ok sample1->wrapWith("out")->string eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
ok sample1->wrapContentWith("out")->parent->string eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
# Editing - inner - wrapWith
ok sample1->go(qw(tail))->go(qw(middle))->wrapWith("MIDDLE")->parent->parent->string eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
ok sample1->go(qw(tail))->go(qw(middle))->wrapContentWith("MIDDLE")->parent->parent->parent->string eq trim(<Hello
thereHowdy
do
doo
HHHHello
to you
END
# Editing - cut/put
if (1)
{my $a = sample2;
ok $a->go(qw(b)) ->id eq q(bb);
ok $a->go(qw(b c))->id eq q(cc);
ok -p $a eq <
END
ok $a->countTags == 3; #TcountTags
my $c = $a->go(qw(b c))->cut; #TputFirst #Tcut
ok -p $a eq <
END
$a->putFirst($c); #TputFirst
ok -p $a eq <
END
$a->putLast($a->go(qw(c))->cut); #TputLast
ok -p $a eq <
END
$a->go(qw(c))->putNext($a->go(q(b))->cut); #TputNext
ok -p $a eq <
END
$a->go(qw(c))->putPrev($a->go(q(b))->cut); #TputPrev
ok -p $a eq <
END
}
# Editing - unwrap
ok sample2->go(qw(b))->unwrap->string eq \'\';
ok sample2->go(qw(b c))->putFirst(sample2)->parent->parent->parent->string eq \'\';
ok sample2->go(qw(b c))->replaceWith(sample2)->go(qw(b c))->upUntil(qw(a b))->string eq \'\';
if (1)
{my $x = sample2;
$x->go(qw(b c))->unwrap;
ok -s $x eq \'\';
$x->go(q(b))->unwrap;
ok -s $x eq \'\';
eval {$x->unwrap };
ok $@ =~ m(\\ACannot unwrap the outer most node)s;
}
if (1) {
my $x = Data::Edit::Xml::new(qq(DDEEFF));#TunwrapContentsKeepingText
ok -p $x eq <
DD
EE
FF
END
$x->go(qw(b))->unwrapContentsKeepingText; #TunwrapContentsKeepingText
ok -p $x eq <
DD EE FF
END
}
if (1)
{my $x = Data::Edit::Xml::new(qq()); #TreplaceWith
$x->go(qw(b c))->replaceWith($x->newTag(qw(d id dd))); #TreplaceWith
ok -s $x eq \'\'; #TreplaceWith
}
if (1)
{my $x = Data::Edit::Xml::new(qq()); #TreplaceWithText
$x->go(qw(b c))->replaceWithText(qq(BBBB)); #TreplaceWithText
ok -s $x eq \'BBBB\'; #TreplaceWithText
}
if (1)
{my $x = Data::Edit::Xml::new(qq()); #TreplaceContentWith
$x->replaceContentWith(map {$x->newTag($_)} qw(B C)); #TreplaceContentWith
ok -s $x eq \'\'; #TreplaceContentWith
}
if (1)
{my $x = Data::Edit::Xml::new(qq()); #TreplaceContentWithText
$x->replaceContentWithText(qw(b c)); #TreplaceContentWithText
ok -s $x eq \'bc\'; #TreplaceContentWithText
}
if (1)
{my $x = Data::Edit::Xml::new(qq()); #TreplaceWithBlank
$x->go(qw(b c))->replaceWithBlank; #TreplaceWithBlank
ok -s $x eq \' \'; #TreplaceWithBlank
}
# Editing - tag /attributes
ok sample2->go(q(b))->change(qw(B b a))->parent->string eq \'\';
ok !sample2->go(q(b))->change(qw(B c a));
ok sample2->go(q(b))->setAttr(aa=>11, bb=>22)->parent->string eq \'\';
ok sample2->go(qw(b c))->setAttr(aa=>11, bb=>22)->parent->parent->string eq \'\';
ok sample2->deleteAttr(qw(id))->string eq \'\';
ok sample2->renameAttr(qw(id ID))->string eq \'\';
ok sample2->changeAttr(qw(ID id))->id eq qq(aa);
ok sample2->renameAttrValue(qw(id aa ID AA))->string eq \'\';
ok sample2->changeAttrValue(qw(ID AA id aa))->id eq qq(aa);
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $b = $a >= \'b\'; #TstringWithConditions
my ($c, $d) = $b->contents; #TstringWithConditions
$b->addConditions(qw(bb BB)); #TstringWithConditions #TaddConditions #TlistConditions #Tcondition #TanyCondition #TallConditions
$c->addConditions(qw(cc CC)); #TstringWithConditions #Tcondition #TanyCondition #TallConditions
ok $c->condition(q(cc)); #Tcondition
ok !$c->condition(q(dd)); #Tcondition
ok $c->condition(q(cc), qw(c b a)); #Tcondition
ok $b->anyCondition(qw(bb cc)); #TanyCondition
ok !$b->anyCondition(qw(cc CC)); #TanyCondition
ok $b->allConditions(qw(bb BB)); #TallConditions
ok !$b->allConditions(qw(bb cc)); #TallConditions
ok join(\' \', $b->listConditions) eq \'BB bb\'; #TdeleteConditions #TaddConditions #TlistConditions
$b->deleteConditions(qw(BB)); #TdeleteConditions
ok join(\' \', $b->listConditions) eq \'bb\'; #TdeleteConditions
ok $a->stringWithConditions eq \'\'; #TstringWithConditions
ok $a->stringWithConditions(qw(bb)) eq \'\'; #TstringWithConditions
ok $a->stringWithConditions(qw(cc)) eq \'\'; #TstringWithConditions
}
if (1)
{my $x = Data::Edit::Xml::new(my $s = <
END
ok $x->attr(qq(number)) == 1; #Tattr
$x->attr(qq(number)) = 2; #Tattr
ok $x->attr(qq(number)) == 2; #Tattr
ok -s $x eq \'\'; #Tattr
$x->attr(qq(delete)) = "me";
ok -s $x eq \'\'; #TdeleteAttr
$x->deleteAttr(qq(delete)); #TdeleteAttr
ok -s $x eq \'\'; #TdeleteAttr #TsetAttr
$x->setAttr(first=>1, second=>2, last=>undef); #TsetAttr
ok -s $x eq \'\'; #TdeleteAttrs #Tattrs #TsetAttr #TgetAttrs #TattrCount
ok $x->attrCount == 3; #TattrCount
ok $x->attrCount(qw(first second third)) == 1; #TattrCount
is_deeply [$x->attrs(qw(third second first ))], [undef, 2, 1]; #Tattrs
is_deeply [$x->getAttrs], [qw(first number second)]; #TgetAttrs
$x->deleteAttrs(qw(first second third number)); #TdeleteAttrs
ok -s $x eq \'\'; #TdeleteAttrs
}
if (1)
{my $a = newTag(undef, q(a), id=>"aa", a=>"1", b=>"1");
ok q() eq -s $a; #Tset
$a->set(a=>11, b=>undef, c=>3, d=>4, e=>5); #Tset
ok q() eq -s $a;
} #Tset
if (1)
{my $a = Data::Edit::Xml::new(\'\'); #TopAttr
ok $a % qq(number) == 1; #TopAttr
}
#if (1)
# {my $a = Data::Edit::Xml::new(""); TopSetTag
# $a += qq(b); TopSetTag
# ok -s $a eq ""; TopSetTag
# }
if (1)
{my $c = Data::Edit::Xml::new(""); #TopWrapWith
my $b = $c / qq(b); #TopWrapWith
ok -s $b eq ""; #TopWrapWith
my $a = $b / qq(a); #TopWrapWith
ok -s $a eq ""; #TopWrapWith
}
if (1)
{my $a = Data::Edit::Xml::new(""); #TopUnWrap
my $b = $a >= \'b\'; #TopUnWrap
++$b; #TopUnWrap
ok -s $a eq ""; #TopUnWrap
}
if (1)
{my $x = Data::Edit::Xml::new(my $s = <
END
ok $x->printAttributes eq qq( no="1" word="first"); #TrenameAttr #TprintAttributes
$x->renameAttr(qw(no number)); #TrenameAttr
ok $x->printAttributes eq qq( number="1" word="first"); #TrenameAttr #TchangeAttr
$x->changeAttr(qw(number word)); #TchangeAttr
ok $x->printAttributes eq qq( number="1" word="first"); #TchangeAttr #TrenameAttrValue
$x->renameAttrValue(qw(number 1 numeral I)); #TrenameAttrValue
ok $x->printAttributes eq qq( numeral="I" word="first"); #TrenameAttrValue #TchangeAttrValue
$x->changeAttrValue(qw(word second greek mono)); #TchangeAttrValue
ok $x->printAttributes eq qq( numeral="I" word="first"); #TchangeAttrValue
$x->changeAttrValue(qw(word first greek mono)); #TchangeAttrValue
ok $x->printAttributes eq qq( greek="mono" numeral="I"); #TchangeAttrValue
}
if (1)
{my $x = Data::Edit::Xml::new(my $s = <
END
ok $x->go(qw(a c)) ->id == 1; #Tgo
ok $x->go(qw(a c -2))->id == 3; #Tgo
ok $x->go(qw(a c *)) == 4; #Tgo
ok 1234 == join \'\', map {$_->id} $x->go(qw(a c *)); #Tgo
$x->go(qw(a c))->wrapTo($x->go(qw(a c -1)), qq(C), id=>1234); #TwrapTo
ok -p $x eq <
END
my $C = $x->go(qw(a C)); #TwrapTo
$C->wrapTo($C, qq(D)); #TwrapTo
ok -p $x eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(my $s = <
END
my $b = $a->first; #TwrapFrom
my @c = $b->contents; #TwrapFrom
$c[1]->wrapFrom($c[0], qw(D id DD)); #TwrapFrom
ok -p $a eq <
END
$c[2]->wrapTo ($c[2], qw(E id EE));
$c[3]->wrapTo ($c[3], qw(F id FF));
ok -p $a eq <
END
}
if (1) # Blank text
{my $f = temporaryFile;
overWriteFile($f, " ");
my $x = Data::Edit::Xml::new($f);
unlink $f;
$x->putFirstAsText(\' \');
$x->go(q(b))->putNextAsText(\' \');
$x->go(q(d))->putPrevAsText(\' \');
$x->putLastAsText(\' \');
ok $x->countTags == 8;
ok $x->contentAsTags eq "CDATA b CDATA c CDATA d CDATA";
my $c = $x->go(qw(c));
$c->replaceWithBlank;
ok $x->countTags == 6;
ok $x->contentAsTags eq "CDATA b CDATA d CDATA";
}
if (1) # Blank text
{my $f = temporaryFile;
overWriteFile($f, " ");
my $x = Data::Edit::Xml::new();
$x->inputFile = $f;
$x->parse;
unlink $f;
$x->putFirstAsText(\' \') for 1..10;
$x->putLastAsText(\' \') for 1..10;
ok $x->countTags == 2;
ok -s $x eq " ";
}
if (!$windows)
{my @files = #TexpandIncludes
(writeFile("in1/a.xml", q()), #TexpandIncludes
writeFile("in2/b.xml", q()), #TexpandIncludes
writeFile("in2/c.xml", q())); #TexpandIncludes
my $x = Data::Edit::Xml::new(fpf(currentDirectory, $files[0])); #TexpandIncludes
$x->expandIncludes; #TexpandIncludes
ok <
END
map{unlink $_} @files;
map{rmdir $_} map {my ($p) = parseFileName $_; $p} @files;
}
else # Skip because absFromRel in expandIncludes does not work on windows
{ok 1;
}
if (1)
{my $a = Data::Edit::Xml::new("A"); #TprettyStringCDATA
my $b = $a->first; #TprettyStringCDATA
$b->first->replaceWithBlank; #TprettyStringCDATA
ok $a->prettyStringCDATA eq <
END
ok $b->first->isText; #TisText
ok $b->first->isText(qw(b a)); #TisText
ok $b->first->isBlankText; #TisBlankText
}
if (1) # Text
{my $x = Data::Edit::Xml::new(<
END
ok $x->count == 0; #Tcount
ok $x->isEmpty; #TisEmpty
ok -s $x eq "";
$x->putFirstAsText(\' \');
ok $x->count == 1;
$x->putFirstAsText("\\n");
ok $x->countTags == 2;
$x->putFirstAsText(\'3\');
ok nn($x->string) eq "3N ";
ok $x->countTags == 2;
ok !$x->isEmpty;
$x->putFirstAsText(\' \');
ok $x->countTags == 2;
$x->putFirstAsText(\' \');
ok $x->countTags == 2;
$x->putFirstAsText(\' 2 \');
ok $x->countTags == 2;
$x->putFirstAsText("\\n");
ok $x->countTags == 2;
$x->putFirstAsText(\' \');
ok $x->countTags == 2;
$x->putFirstAsText(\' 1 \');
ok $x->countTags == 2;
$x->putFirstAsText(\' \');
ok $x->countTags == 2;
$x->putFirstAsText(\' \');
ok $x->first->tag eq qq(CDATA);
ok $x->first->isText;
ok $x->countTags == 2;
ok nn($x->string) eq " 1 N 2 3N ";
}
if (1) # Text and tags
{my $x = Data::Edit::Xml::new(<
END
$x->by(sub
{my ($o) = @_;
$o->putFirstAsText($_) for (\' \', \'F\', \'\', \'F\', \' \', \'\');
$o->putLastAsText ($_) for (\' \', \'L\', \'\', \'L\', \'\', \' \');
unless($o == $x)
{$o->putNextAsText ($_) for (\' N \', \' N \', \'\', \' N \', \' \', \' N \'); # N will always be preceded and succeeded by spaces
$o->putPrevAsText ($_) for (\' P\', \'\' , \'\', \' P\', \' \', \' P\') # P will always be preceded by spaces
}
});
ok -s $x eq " FF P P P FF LL N N N N P P P FF LL N N N N LL ";
}
if (1)
{my $x = Data::Edit::Xml::new(<
END
ok $x->go(q(b))->contentAsTags eq \'c d e f g\'; #TcontentAsTags
ok \'f g\' eq join \' \', map {$_->tag} $x->go(qw(b e))->contentAfter; #TcontentAfterAsTags
ok \'c d\' eq join \' \', map {$_->tag} $x->go(qw(b e))->contentBefore; #TcontentBeforeAsTags
ok $x->go(qw(b e))->contentAfterAsTags eq \'f g\'; #TcontentAfterAsTags
ok $x->go(qw(b e))->contentBeforeAsTags eq \'c d\'; #TcontentBeforeAsTags
ok \'f g\' eq join \' \', map {$_->tag} $x->go(qw(b e))->contentAfter; #TcontentAfter
ok \'c d\' eq join \' \', map {$_->tag} $x->go(qw(b e))->contentBefore; #TcontentBefore
ok $x->go(q(b))->over(qr(d.+e)); #Tover
ok $x->go(q(b))->over2(qr(\\A c d e f g \\Z)); #Tover2
ok $x->go(q(b))->contentAsTags eq q(c d e f g) ; #Tover2
ok $x->go(q(b))->contentAsTags2 eq q( c d e f g ); #TcontentAsTags2
ok $x->go(qw(b e))->matchAfter (qr(\\Af g\\Z)); #TmatchAfter
ok $x->go(qw(b e))->matchAfter2 (qr(\\A f g \\Z)); #TmatchAfter2
ok $x->go(qw(b e))->contentAfterAsTags2 eq q( f g ); #TcontentAfterAsTags2
ok $x->go(qw(b e))->matchBefore (qr(\\Ac d\\Z)); #TmatchBefore
ok $x->go(qw(b e))->matchBefore2(qr(\\A c d \\Z)); #TmatchBefore2
ok $x->go(qw(b e))->contentBeforeAsTags2 eq q( c d ); #TcontentBeforeAsTags2
}
if (1)
{my $a = Data::Edit::Xml::new(<
ccc
eee
END
my ($b, $d) = @$a; #TopContents
ok -c $b eq q(b a); #TopContents
my ($c) = @$b; #TopContents
my ($e) = @$d;
ok -c $c eq q(c b a); #TopContents
-X $c;
ok -p $a eq <
eee
END
-W $e;
ok -p $a eq <
eee
END
-R $d;
ok -p $a eq <
<d>eee</d>
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $b, $e, $d) = $a->byList; #TopString
ok $c->printNode eq q(c id="42" match="mm"); #TopString #TprintNode
ok -A $c eq q(c id="42" match="mm"); #TopString
my ($E, $D, $C, $B) = $a->byReverseList; #TbyReverseList
ok -A $C eq q(c id="42" match="mm"); #TbyReverseList
ok -b $e; #TopString
ok -c $e eq q(e d a); #TopString #TbyList
ok -f $b eq $c; #TopString
ok -l $a eq $d; #TopString
ok -O $a, q( b d ); #TopString
ok -o $a, q(b d); #TopString
ok -w $a eq q(\'\'); #TopString
ok -p $a eq <
END
ok -s $a eq \'\'; #TopString #Tstring
ok -t $a eq \'a\'; #TopString
$a->numberTree; #TopString #TnumberTree
ok -z $a eq <
END
ok \'bd\' eq join \'\', map {$_->tag} @$a ;
ok (($a >= [qw(d e)]) <= [qw(e d a)]); #TopGo #TopAt
ok $a->go(qw(d e))->context eq \'e d a\'; #Tcontext
ok $a->go(q(b))->isFirst; #TisFirst
ok $a->go(q(d))->isLast; #TisLast
if (1)
{my $s; $a->down(sub{$s .= $_->tag}); ok $s eq "abcde" #Tdown #TdownX
}
if (1)
{my $s; $a->downReverse(sub{$s .= $_->tag}); ok $s eq "adebc" #TdownReverse #TdownReverseX
}
if (1)
{my $s; $a->by(sub{$s .= $_->tag}); ok $s eq "cbeda" #Tby
}
if (1)
{my $s; $a->byX(sub{$s .= $_->tag}); ok $s eq "cbeda" #TbyX
}
if (1)
{my $s; $a x= sub{$s .= -t $_}; ok $s eq "cbeda" #TopBy
}
if (1)
{my $s; $a->byReverse(sub{$s .= $_->tag}); ok $s eq "edcba" #TbyReverse #TbyReverseX
}
if (1)
{my $s; my $n = sub{$s .= $_->tag}; $a->through($n, $n); #Tthrough #TthroughX
ok $s eq "abccbdeeda" #Tthrough #TthroughX
}
}
if (1)
{my $x = Data::Edit::Xml::new(<
END
my $b = $x >= qq(b); #TopCut
--$b; #TopCut
ok -s $x eq ""; #TopCut
ok -s $b eq ""; #TopCut
}
if (1)
{my $a = Data::Edit::Xml::new(\'\');
ok -p $a eq <
END
my $f = $a >> qq(first); #TopPutFirst
ok -p $a eq <
END
my $l = $a << qq(last); #TopPutLast
ok -p $a eq <
END
$f += qq(next); #TopPutNext
ok -p $a eq <
END
$l -= qq(prev); #TopPutPrev
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(\'\');
ok -p $a eq <
END
my $n = $a ** qq(z);
ok $n->tag eq q(z);
$a >>= qq(first); #TopPutFirstAssign
ok -p $a eq <
END
$a <<= qq(last); #TopPutLastAssign
ok -p $a eq <
END
my $f = -f $a; #TopPutNextAssign
$f += qq(next); #TopPutNextAssign
ok -p $a eq <
END
my $l = -l $a; #TopPutPrevAssign
$l -= qq(prev); #TopPutPrevAssign
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(""); #TopNew
my $b = $a ** q(b); #TopNew
ok -s $b eq ""; #TopNew
}
if (1) # NextOn
{my $a = Data::Edit::Xml::new("");
ok -p $a eq <
END
my $c = $a->firstContextOf(qw(c));
my $e = $a->lastContextOf(qw(e));
ok $c->id == 1; #TnextOn #TprevOn
ok $e->id == 5; #TnextOn #TprevOn
ok $c->nextOn(qw(d)) ->id == 2; #TnextOn
ok $c->nextOn(qw(c d))->id == 4; #TnextOn
ok $e->nextOn(qw(c d)) == $e; #TnextOn
ok $e->prevOn(qw(d)) ->id == 4; #TprevOn
ok $e->prevOn(qw(c d)) == $c; #TprevOn
my $x = $a >= [qw(b c 1)];
my $w = $x->prev;
my $y = $x->next;
ok -s $w eq \'\';
ok -s $y eq \'\';
is_deeply {$a->first->present}, {c=>2, d=>2, e=>1}; #Tpresent
}
if (1) # Put as text
{my $x = Data::Edit::Xml::new(<
END
ok -p $x eq <
END
$x->go(qw(b c))->putFirstAsText("DDDD"); #TputFirstAsText
ok -p $x eq <
DDDD
END
$x->go(qw(b c))->putLastAsText("EEEE"); #TputLastAsText
ok -p $x eq <
DDDDEEEE
END
$x->go(qw(b c))->putNextAsText("NNNN"); #TputNextAsText
ok -p $x eq <
DDDDEEEE
NNNN
END
$x->go(qw(b c))->putPrevAsText("PPPP
"); #TputPrevAsText
ok -p $x eq <
PPPP
DDDDEEEE
NNNN
END
}
if (1) #TfirstText #TlastText #TnextText #TprevText
{my $a = Data::Edit::Xml::new("AABBCCDDHH");
ok -p $a eq <AA
BB
CC
DD
HH
END
ok $a->firstText_a__text eq q(AA);
ok !$a->go_c__firstText_c_a;
ok !$a->go_c__firstText_c_b;
ok $a->lastText__text eq q(HH);
ok $a->lastText_a__text eq q(HH);
ok !$a->go_c__lastText;
ok $a->go_c__nextText_c_a__text eq q(CC);
ok !$a->go_e__nextText;
ok $a->go_c__prevText_c__text eq q(BB);
ok !$a->go_e__prevText;
}
if (1)
{my $a = Data::Edit::Xml::new(<
ddd
END
$a->first->replaceContentWithMovedContent($a->go(qw(b c d)));
ok -p $a eq <
ddd
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($b, $c, $d) = $a->contents; #TreplaceContentWithMovedContent
$d->replaceContentWithMovedContent($c, $b); #TreplaceContentWithMovedContent
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($d) = $a->contents; #TreplaceContentWithMovedContent
my ($b, $c) = $d->contents; #TreplaceContentWithMovedContent
$d->replaceContentWithMovedContent($c, $b); #TreplaceContentWithMovedContent
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
ok $a->go(qw(b 1))->id == 23; #Tindex
ok $a->go(qw(b 1))->index == 1; #Tindex
ok $a->go(qw(b 1 b))->id == 26; #Tposition
ok $a->go(qw(b 1 b))->position == 2; #Tposition
ok $a->go(q(b))->first->id == 13; #Tfirst
ok $a->go(q(b))->first(qw(c b a)); #Tfirst
ok !$a->go(q(b))->first(qw(b a)); #Tfirst
ok $a->go(qw(b b))->firstSibling->id == 13; #TfirstSibling
ok $a->go(qw(b b))->lastSibling ->id == 22; #TlastSibling
ok $a->go(q(b))->last ->id == 22; #Tlast
ok $a->go(q(b))->last(qw(g b a)); #Tlast
ok !$a->go(q(b))->last(qw(b a)); #Tlast
ok !$a->go(q(b))->last(qw(b a)); #Tlast
ok $a->go(qw(b b e))->next ->id == 19; #Tnext
ok $a->go(qw(b b e))->next(qw(f b b a)); #Tnext
ok !$a->go(qw(b b e))->next(qw(f b a)); #Tnext
ok $a->go(qw(b b e))->prev ->id == 17; #Tprev
ok $a->go(qw(b b e))->prev(qw(d b b a)); #Tprev
ok !$a->go(qw(b b e))->prev(qw(d b a)); #Tprev
if (1)
{my %f = $a->firstBy; #TfirstBy
ok $f{b}->id == 12; #TfirstBy
}
if (1)
{my %f = $a->firstDown; #TfirstDown
ok $f{b}->id == 15; #TfirstDown
}
if (1)
{my %l = $a->lastBy; #TlastBy
ok $l{b}->id == 23; #TlastBy
}
if (1)
{my %l = $a->lastDown; #TlastDown
ok $l{b}->id == 26; #TlastDown
}
}
if (1)
{my $x = Data::Edit::Xml::new(<
DD11
EE11
DD22
EE22
DD33
EE33
END
ok $x->firstContextOf(qw(d c)) ->id eq qq(d1); #TfirstContextOf
ok $x->firstContextOf(qw(e c b2)) ->id eq qq(e2); #TfirstContextOf
ok $x->firstContextOf(qw(CDATA d c b2))->string eq qq(DD22); #TfirstContextOf
ok $x-> lastContextOf(qw(d c)) ->id eq qq(d3); #TlastContextOf
ok $x-> lastContextOf(qw(e c b2 )) ->id eq qq(e2); #TlastContextOf
ok $x-> lastContextOf(qw(CDATA e c b2))->string eq qq(EE22); #TlastContextOf
}
if (1) # New
{my $x = Data::Edit::Xml::newTree("a", id=>1, class=>"aa"); #TnewTree #TnewTag
ok -s $x eq \'\'; #TnewTree
ok $x->attrCount == 2;
$x->putLast($x->newTag("b", id=>2, class=>"bb")); #TnewTag
ok $x->go(q(b))->attrCount == 2;
ok -p $x eq <
END
$x->putLast($x->newText("t")); #TnewText
ok -p $x eq <
t
END
}
if (1) # Well known attributes
{my $a = Data::Edit::Xml::newTree("a", id=>1, class=>2, href=>3, outputclass=>4); #TcountOutputClasses
ok $a->id == 1;
ok $a->class == 2;
ok $a->href == 3;
ok $a->outputclass == 4;
is_deeply { 4 => 1 }, $a->countOutputClasses; #TcountOutputClasses
}
if (1) # Spares
{my $c = Data::Edit::Xml::newTree("c", id=>33); #TwrapUp
my ($b, $a) = $c->wrapUp(qw(b a)); #TwrapUp
ok -p $a eq <<\'END\'; #TwrapUp
END
}
if (1)
{my $a = Data::Edit::Xml::newTree("a", id=>33); #TwrapDown
my ($b, $c) = $a->wrapDown(qw(b c)); #TwrapDown
ok $a->tag eq qq(a);
ok $b->tag eq qq(b);
ok $c->tag eq qq(c);
ok $a->id == 33;
ok -p $a eq <
END
}
if (1) # Matches text
{my $x = Data::Edit::Xml::new(<
CDECD
END
my $c = $x->go(qw(b c))->first; #TmatchesText
ok !$c->matchesText(qr(\\AD)); #TmatchesText
ok $c->matchesText(qr(\\AC), qw(c b a)); #TmatchesText
ok !$c->matchesText(qr(\\AD), qw(c b a)); #TmatchesText
is_deeply [qw(E)], [$c->matchesText(qr(CD(.)CD))]; #TmatchesText
}
if (1) # Create
{my $x = Data::Edit::Xml::new(<
E
END
$x->go(qw(d G))->replaceWithBlank;
ok $x->prettyStringCDATA eq <
E
END
ok \'100\' eq -B $x; #TbitsNodeTextBlank
ok \'100\' eq -B $x->go(q(b)); #TbitsNodeTextBlank
ok \'110\' eq -B $x->go(q(c)); #TbitsNodeTextBlank
ok \'111\' eq -B $x->go(q(d)); #TbitsNodeTextBlank
ok !-B $x->go(qw(e)); #TbitsNodeTextBlank
}
if (!$windows) # Default error file
{my $a = eval {Data::Edit::Xml::new("")};
my ($m, $f) = split /\\n/, $@;
ok $m =~ m(Xml parse error, see file:)s;
ok -e $f;
unlink $f;
$f =~ s\'out.data\'\';
rmdir $f;
}
else
{ok 1 for 1..2;
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->by(sub{$_->replaceWithBlank(qw(z))}); #TisAllBlankText
my ($b, $c, $d) = $a->firstBy(qw(b c d)); #TisAllBlankText
ok !$b->isEmpty;
ok !$b->isAllBlankText;
ok !$c->isEmpty;
ok $c->isAllBlankText; #TisAllBlankText
ok $c->isAllBlankText(qw(c b a)); #TisAllBlankText
ok !$c->isAllBlankText(qw(c a)); #TisAllBlankText
ok $d->isEmpty;
ok $d->isEmpty(qw(d a));
ok !$d->isEmpty(qw(d b));
ok $d->isAllBlankText;
ok $d->isAllBlankText(qw(d a));
ok !$d->isAllBlankText(qw(d b));
ok $a->first(qw(b a)) == $b;
ok !$a->first(qw(a));
ok $a->last(qw(d a)) == $d;
ok !$a->last(qw(a));
ok $b->next(qw(d a)) == $d;
ok !$b->next(qw(a));
ok $d->prev(qw(b a)) == $b;
ok !$d->prev(qw(a));
ok $b->isFirst;
ok $b->isFirst(qw(b a));
ok !$b->isFirst(qw(a));
ok $d->isLast;
ok $d->isLast(qw(d a));
ok !$d->isLast(qw(a));
$d->props = q(Props);
$d->otherprops = q(OtherProps);
$d->style = q(Style);
ok $d->printAttributes eq
q( otherprops="OtherProps" props="Props" style="Style");
my $D = $d->countAttrNames;
is_deeply $D, { otherprops => 1, props => 1, style => 1 };
ok $c->at(q(c), undef, q(a));
ok !$c->cut(qw(b a));
}
if (1) # Unwrap
{my $x = Data::Edit::Xml::new("");
$x->go(qw(b c))->unwrap;
$x->checkParentage;
ok -s $x eq "";
$x->go(q(b))->unwrap;
ok -s $x eq "";
eval {$x->unwrap};
ok $@ =~ /\\ACannot unwrap the outer most node/gs;
}
if (1)
{my $a = Data::Edit::Xml::new(" "); #Tequals #Tclone
my $A = $a->clone; #Tequals #Tclone
ok -s $A eq q(); #Tequals #Tclone
ok $a->equals($A); #Tequals #Tclone
}
if (1)
{my $a = Data::Edit::Xml::new(""); #Trenew
$a->putFirstAsText(qq()); #Trenew
ok !$a->go(q(b)); #Trenew
my $A = $a->renew; #Trenew
ok -t $A->go(q(b)) eq q(b) #Trenew
}
if (1) #TnumberTree #TfindByNumber #Tnumber
{my $a = Data::Edit::Xml::new(<
END
$a->numberTree;
ok -z $a eq <
END
ok -t $a->findByNumber_4 eq q(d);
ok $a->findByNumber_3__up__number == 2;
}
if (1) #Tup #Tupn #TupUntil #TupWhile
{my $a = Data::Edit::Xml::new(<
END
$a->numberTree;
ok -z $a eq <
END
my $c = $a->findByNumber(8);
ok -t $c eq q(c);
ok $c->up_b__number == 7;
ok $c->upn_2__number == 6;
ok $c->upWhile_b__number == 4;
ok $c->upWhile_a_b__number == 4;
ok $c->upWhile_b_c__number == 2;
ok $c->upUntil__number == 7;
ok $c->upUntil_b_c__number == 4;
}
if (1)
{ok Data::Edit::Xml::cdata eq q(CDATA); #Tcdata
ok Data::Edit::Xml::replaceSpecialChars(q(<">)) eq q(<">); #TreplaceSpecialChars
ok Data::Edit::Xml::undoSpecialChars(q(<">)) eq q(<">); #TundoSpecialChars
}
if (1) # Break in and out
{my $A = Data::Edit::Xml::new(""); #TbreakOut
ok -p $A eq <
END
if (1)
{my $a = $A->clone;
$a->go(q(b))->breakOut($a, qw(d e)); #TbreakOut
ok -p $a eq <
END
$a->go(qw(b 1))->breakIn; #TbreakIn
ok -p $a eq <
END
$a->go(q(b))->breakOut($a, qw(d e)); # Break backwards
ok -p $a eq <
END
$a->go(qw(b 1))->breakInBackwards; #TbreakInBackwards
ok -p $a eq <
END
my $d = $a->go(q(d))->cut;
eval {$d->putLast($d)};
ok $@ =~ m/\\ARecursive insertion attempted/s;
$a->go(q(b))->putLast($d);
ok $A->equals($a);
$a->go(q(b))->breakOut($a, qw(d e));
ok -p $a eq <
END
$a->go(q(b))->breakInForwards; #TbreakInForwards
ok -p $a eq <
END
my $D = $a->go(q(d))->cut;
eval {$D->putFirst($D)};
ok $@ =~ m/\\ARecursive insertion attempted/s;
$a->go(q(b))->putFirst($D);
ok $A->equals($a);
}
}
if (1)
{my @tags = qw(a b c d e);
my $x = Data::Edit::Xml::new(<
END
my ($a, $b, $c, $d, $e) = $x->firstDown(@tags); #TabovePath #TbelowPath
my ($A, $B, $C, $D, $E) = $x->lastDown(@tags);
is_deeply [$b, $d, $e], [$b->abovePath($e)]; #TabovePath
is_deeply [$e, $d, $b], [$e->belowPath($b)]; #TbelowPath
is_deeply [], [$c->abovePath($d)]; #TabovePath
is_deeply [$c], [$c->belowPath($c)]; #TbelowPath
ok eval \' $\'.$_ .\'->tag eq "\'.$_.\'"\' for @tags; # Tags equal their variable names
ok eval \' $\'.uc($_).\'->tag eq "\'.$_.\'"\' for @tags; # Tags equal their lowercased uppercase variable names
ok eval \' $\'.$_ .\'->ordered($\'.uc($_).\')->tag eq $\'.$_.\'->tag\' for @tags;# Lowercase nodes precede uppercase nodes
ok eval \'!$\'.uc($_).\'->ordered($\'.$_ .\') or $\'.$_.\' == $\'.uc($_) for @tags;# Uppercase nodes equal lowercase nodes or do not precede them
ok $A == $a;
ok $B == $b;
ok $C == $b->go(qw(c 5));
ok $D == $b->go(qw(d -1));
ok $E == $D->go(qw(e));
is_deeply [$x->go(qw(b d 1 e))->path], [qw(b d 1 e)]; #Tpath
$x->by(sub {ok $x->go($_->path) == $_}); #Tpath
ok $a->id eq \'a1\';
ok $b->id eq \'b1\'; #Tdisordered #Tabove
ok $c->id eq \'c1\'; #Tdisordered #Tafter
ok $d->id eq \'d1\'; #Tdisordered #Tbelow
ok $e->id eq "e1"; #Tordered #Tabove #Tbelow #Tdisordered #Tbefore #Tafter
ok $E->id eq "e2"; #Tordered #Tabove #Tbefore
ok $b->above($e); #Tabove
ok !$E->above($e); #Tabove
ok !$d->below($e); #Tbelow
ok $e->disordered($c )->id eq "c1"; #Tdisordered
ok $b->disordered($c, $e, $d)->id eq "d1"; #Tdisordered
ok !$c->disordered($e); #Tdisordered
ok $e->ordered($E); #Tordered
ok !$E->ordered($e); #Tordered
ok $e->ordered($e); #Tordered
ok $e->ordered; #Tordered
ok $a->ordered($b,$c,$d,$e);
ok $A->ordered($B,$D,$E,$C);
is_deeply[map{$_->tag}$a->firstDown(@tags)],[map{$_->tag}$a-> lastBy(@tags)];
is_deeply[map{$_->tag}$a-> lastDown(@tags)],[map{$_->tag}$a->firstBy(@tags)];
ok $e->before($E); #Tbefore
ok $e->after($c); #Tafter
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
ok $a->go(qw(b c -1 f))->at(qw(f c b a)); #Tat
ok $a->go(qw(b c 1 e))->at(undef, qr(c|d), undef, qq(a)); #Tat
my $d = $a->go(qw(b c d));
ok $d->context eq q(d c b a); #Tat #TatOrBelow
ok $d->at(qw(d c b), undef); #Tat
ok !$d->at(qw(d c b), undef, undef); #Tat
ok !$d->at(qw(d e b)); #Tat
ok $d->atOrBelow(qw(d c b a)); #TatOrBelow
ok $d->atOrBelow(qw( c b a)); #TatOrBelow
ok $d->atOrBelow(qw( b a)); #TatOrBelow
ok !$d->atOrBelow(qw( c a)); #TatOrBelow
}
if (1)
{my $a = Data::Edit::Xml::new(qq( ));
ok !$a->bitsNodeTextBlank && $a->isEmpty;
}
if (1)
{my $a = Data::Edit::Xml::new(qq(B ));
ok $a->bitsNodeTextBlank && !$a->isEmpty;
}
if (1) # Numbered
{my $a = Data::Edit::Xml::new(<
END
$a->numberTree;
ok -z $a eq <
END
is_deeply [$a->findByNumber(11)->path], [(qw(b d 1 e))]; # FindByNumber
ok $a->findByNumber(9)->pathString eq \'b c 1 d e\'; #TpathString
ok !$a->above($a); # Above
ok $a->findByNumber(12)->above($a->findByNumber(14));
ok !$a->findByNumber( 7)->above($a->findByNumber(12));
ok !$a->below($a); # Below
ok $a->findByNumber( 9)->below($a->findByNumber(7));
ok !$a->findByNumber( 8)->below($a->findByNumber(10));
ok $a->findByNumber(13)->after($a->findByNumber(10));
if (1)
{my ($m, $n) = $a->findByNumbers(5, 10);
ok $m->before($n);
}
ok $a->findByNumber (5)->firstInIndex; #TfirstInIndex
ok $a->findByNumber(10)->lastInIndex; #TlastInIndex
ok !$a->findByNumber(7) ->firstInIndex; #TfirstInIndex
ok !$a->findByNumber(7) ->lastInIndex; #TlastInIndex
if (1)
{my ($b, $e, @n) = $a->findByNumbers(2, 4, 6, 9); #TcommonAncestor
ok -t $b eq \'b\';
ok -t $e eq \'e\';
ok $e == $e->commonAncestor; #TcommonAncestor
ok $e == $e->commonAncestor($e); #TcommonAncestor
ok $b == $e->commonAncestor($b); #TcommonAncestor
ok $e == $e->commonAncestor($e, $e);
ok $b == $e->commonAncestor($e, $b);
ok $b == $e->commonAncestor(@n); #TcommonAncestor
}
if (1)
{my ($d, $c, $D) = $a->findByNumbers(5, 7, 10); #TfromTo #Tto #Tfrom
ok -t $d eq \'d\';
ok -t $c eq \'c\';
ok -t $D eq \'d\';
my @r = $d->fromTo($D); #TfromTo
ok @r == 3; #TfromTo
my @R = $d->fromTo($D, qw(c)); #TfromTo
ok @R == 1; #TfromTo
ok -M $R[0] == 7; #TfromTo
ok !$D->fromTo($d); #TfromTo
ok 1 == $d->fromTo($d); #TfromTo
my @f = $d->from; #Tfrom
ok @f == 4; #Tfrom
ok $d == $f[0]; #Tfrom
my @F = $d->from(qw(c)); #Tfrom
ok @F == 2; #Tfrom
ok -M $F[1] == 12; #Tfrom
my @t = $D->to; #Tto
ok $D == $t[-1]; #Tfrom
ok @t == 4; #Tto
my @T = $D->to(qw(c)); #Tto
ok @T == 2; #Tto
ok -M $T[1] == 7; #Tto
}
ok 0 == $a->depth; #Tdepth
ok 4 == $a->findByNumber(14)->depth; #Tdepth
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
is_deeply [qw(c d d)], [map {-t $_} $a->go(q(b))->firstOf(qw(c d))]; #TfirstOf
is_deeply [qw(d d c)], [map {-t $_} $a->go(q(b))->lastOf (qw(c d))]; #TlastOf
}
if (1) # IsOnlyChild
{my $a = Data::Edit::Xml::new("");
ok $a->go(qw(b c d))->isOnlyChild;
ok $a->go(qw(b c d))->isOnlyChild(qw(d));
ok $a->go(qw(b c d))->isOnlyChild(qw(d c));
ok $a->go(qw(b c d))->isOnlyChild(qw(d c b));
}
if (1)
{my $a = Data::Edit::Xml::new("bbccee"); #TcontainsSingleText
ok $a->go(q(b))->containsSingleText->text eq q(bb); #TcontainsSingleText
ok !$a->go(q(c))->containsSingleText; #TcontainsSingleText
}
if (1) # Cut
{my $x = Data::Edit::Xml::new("");
$x->go(qw(b c))->cut;
$x->checkParentage;
ok -s $x eq "";
$x->go(q(b))->cut;
ok -s $x eq "";
eval {$x->cut};
ok !$@; # Permit multiple cut outs of the same node
}
if (1) # Cut blank
{my $x = Data::Edit::Xml::new("AB");
my $b = $x->go(q(b));
$b->putFirst($x->newText(\' c \'));
ok -s $x eq "A c B"; #Tunwrap
$b->unwrap; #Tunwrap
ok -s $x eq "A c B"; #Tunwrap
}
if (1) # Errors
{my $f = temporaryFile;
my $e = temporaryFile;
overWriteFile($f, <
END
my $x = Data::Edit::Xml::new();
$x->input = $f;
$x->errorsFile = $e;
eval {$x->parse};
ok $@ =~ /\\AXml parse error, see file:/;
ok -e $e;
my $s = readFile($e);
ok CORE::index($s, $f) > 0;
ok $s =~ /no element found at line 2, column 0, byte 4/s;
unlink $e, $f;
}
if (1) # Unwrap/Cut in by
{my $f = temporaryFile;
overWriteFile($f, <
END
my $x = Data::Edit::Xml::new();
$x->input = $f;
$x->parse;
unlink $f;
my $A = 0;
$x->checkParser;
$x->by(sub # Add stuff and move things around
{my ($o) = @_;
for my $t(\'\', \' \', \'aa\', 11)
{$o->putFirst($x->newTag(q(a))) if ++$A % 3 == 0;
$o->putLast ($x->newTag(q(b))) if ++$A % 5 == 0;
if ($o->parent)
{$o->putNext ($x->newTag(q(c))) if ++$A % 7 == 0;
$o->putPrev ($x->newTag(q(d))) if ++$A % 2 == 0;
$o->putFirstAsText($t) if ++$A % 3 == 0;
$o->putLastAsText ($t) if ++$A % 2 == 0;
$o->putNextAsText ($t) if ++$A % 3 == 0;
$o->putPrevAsText ($t) if ++$A % 2 == 0;
}
$o->wrapContentWith(qw(ww)) if ++$A % 5 == 0;
$o->wrapWith(qw(xx)) if ++$A % 3 == 0;
$o->wrapUp (qw(aa bb)) if ++$A % 5 == 0;
$o->wrapDown(qw(cc dd)) if ++$A % 7 == 0;
if (my $p = $o->parent)
{if(!$p->above($o))
{$p->putFirst ($o->cut) if ++$A % 2 == 0;
$p->putLast ($o->cut) if ++$A % 5 == 0;
$p->replaceWith ($o->cut) if ++$A % 2 == 0;
if (my $q = $p->parent)
{$p->putNext ($o->cut) if ++$A % 2 == 0;
$p->putPrev ($o->cut) if ++$A % 2 == 0;
$q->putLast ($o->cut) if ++$A % 3 == 0;
$q->putNext ($o->cut) if ++$A % 5 == 0;
$q->putPrev ($o->cut) if ++$A % 3 == 0;
$q->putFirst ($o->cut) if ++$A % 3 == 0;
$q->replaceWith($o->cut) if ++$A % 3 == 0;
}
}
}
}
});
is_deeply $x->countTagNames,
{a => 1,
aa => 22,
b => 27,
B => 3,
bb => 22,
C => 10,
c => 27,
cc => 16,
CDATA => 168,
d => 112,
dd => 16,
ww => 23,
};
ok $x->countTags == 447;
$x->checkParentage;
ok $x->equals($x); # Equals and clone
my $y = $x->clone;
my $z = $y->clone;
ok $y->equals($x);
ok $y->equals($y);
ok $y->equals($z);
ok $x->equals($z);
ok $y->by(sub
{if ($_->at(q(C)))
{$_->change(q(D));
}
});
ok !$y->equals($z);
if (1) # Save restore
{my $f = temporaryFile;
unlink $f;
my $y1 = eval {Data::Edit::Xml::restore($f)};
ok $@ =~ /Cannot restore from a non existent file/gs;
$y->save($f); #Tsave #Trestore
my $Y = Data::Edit::Xml::restore($f); #Tsave #Trestore
unlink $f;
ok $Y->equals($y); #Tsave #Trestore
}
my $a = 0; # Cut and unwrap
$x->by(sub
{my $t = $_->tag;
eval {$x->cut};
eval {$x->unwrap};
eval {$_->cut} if ++$a % 2;
eval {$_->unwrap} if ++$a % 2;
});
$x->checkParentage;
ok -s $x eq "";
}
if (1) # First of
{my $x = Data::Edit::Xml::new(<
END
ok !$x->firstContextOf(qw(c a));
ok !$x-> lastContextOf(qw(c a));
ok $x->firstContextOf(qw(c b))->id == 1;
ok $x->firstContextOf(qw(c d))->id == 2;
ok $x->firstContextOf(qw(c e))->id == 3;
ok $x-> lastContextOf(qw(c b))->id == 4;
ok $x-> lastContextOf(qw(c d))->id == 5;
ok $x-> lastContextOf(qw(c e))->id == 6;
is_deeply [map{-u $_} $x->c(q(d))], [qw(d1 d2)]; #Tc
is_deeply [map{-u $_} $x->contents], [qw(b1 d1 e1 b2 d2 e2)]; #Tcontents
}
if (1) # Special characters
{my $t =
\'"<>"<>\';
my $x = Data::Edit::Xml::new($t);
ok -s $x eq $t;
}
if (1)
{my $s = <
END
my $a = Data::Edit::Xml::new($s); #TprettyString #Tconcatenate
ok $s eq $a->prettyString; #TprettyString
ok $s eq -p $a; #TprettyString
ok $a->stringContent eq ""; #TstringContent
ok $a->stringQuoted eq q(\'\'); #TstringQuoted
ok $a->prettyStringContent eq <
END
$a->numberTree; #TprettyStringNumbered #TfindByNumber #TfindByNumbers #Tancestry
ok $a->prettyStringNumbered eq <
END
if (1)
{my $t = $a->tocNumbers(qw(b A B));
is_deeply {map {$_=>$t->{$_}->tag} keys %$t}, {"1"=>"b", "1 1"=>"A", "1 2"=>"B"}
}
if (1)
{my $t = $a->tocNumbers(qw(b c A B C));
is_deeply {map {$_=>$t->{$_}->tag} keys %$t}, { "1" => "b", "1 1" => "A", "1 2" => "B", "2" => "c", "2 1" => "C" }
}
if (1) {
my $t = $a->tocNumbers(); #TtocNumbers
is_deeply {map {$_=>$t->{$_}->tag} keys %$t}, #TtocNumbers
{"1" =>"b", #TtocNumbers
"1 1"=>"A", #TtocNumbers
"1 2"=>"B", #TtocNumbers
"2" =>"c", #TtocNumbers
"2 1"=> "C", #TtocNumbers
"2 2"=>"D" #TtocNumbers
} #TtocNumbers
}
ok q(D) eq -t $a->findByNumber(7); #TfindByNumber
is_deeply [map {-t $_} $a->findByNumbers(1..3)], [qw(a b A)]; #TfindByNumbers
is_deeply [map {-t $_} $a->findByNumber(7)->ancestry], [qw(D c a)]; #Tancestry
$a->go(q(b))->concatenate($a->go(q(c))); #Tconcatenate
my $t = <
END
ok $t eq -p $a; #Tconcatenate
}
if (1)
{my $s = <
END
my $a = Data::Edit::Xml::new($s); #TprettyStringContentNumbered
$a->numberTree; #TprettyStringContentNumbered
ok $a->prettyStringContentNumbered eq <
END
ok $a->go(qw(b))->prettyStringContentNumbered eq <
END
}
if (1) # concatenateSiblings
{my $a = Data::Edit::Xml::new(\'\');
ok -p $a eq <
END
$a->go(qw(b 3))->concatenateSiblings; #TconcatenateSiblings
ok -p $a eq <
END
$a->concatenateSiblings;
ok -s $a eq \'\';
}
if (1)
{my $a = Data::Edit::Xml::new(\'\'); #Tchange
$a->change(qq(b)); #Tchange
ok -s $a eq \'\'; #Tchange
}
if (1)
{my $x = Data::Edit::Xml::new(<
END
is_deeply $x->countTagNames, { a => 1, b => 2, c => 3 }; #TcountTagNames
is_deeply $x->countAttrNames, { A => 1, B => 2, C => 4 }; #TcountAttrNames
is_deeply $x->countAttrValues, { A => 1, B => 2, C => 4 }; #TcountAttrValues
}
if (1) # *NonBlank
{my $a = Data::Edit::Xml::new
("123456789");
map {$_->replaceWithBlank} grep {$_->isText} $a->contents;
map {$_->cut} grep {$_->tag =~ m/\\A[BDFH]\\Z/} $a->contents;
ok $a->prettyStringCDATA eq <<\'END\'; #TfirstNonBlank #TnextNonBlank #TfirstIn #TnextIn #TlastNonBlank #TprevNonBlank #TlastIn #TprevIn
END
ok $a->firstNonBlank->tag eq qq(A); #TfirstNonBlank
ok $a->firstNonBlank(qw(A a)); #TfirstNonBlank
ok $a->firstNonBlank->nextNonBlank->tag eq qq(C); #TnextNonBlank
ok $a->firstNonBlank->nextNonBlank(qw(C a)); #TnextNonBlank
ok $a->firstIn(qw(b B c C))->tag eq qq(C); #TfirstIn
ok $a->firstIn(qw(b B c C))->nextIn(qw(A G))->tag eq qq(G); #TnextIn
ok $a->lastNonBlank->tag eq qq(G); #TlastNonBlank
ok $a->lastNonBlank(qw(G a)); #TlastNonBlank
ok $a->lastNonBlank->prevNonBlank->tag eq qq(E); #TprevNonBlank
ok $a->lastNonBlank->prevNonBlank(qw(E a)); #TprevNonBlank
ok $a->lastIn(qw(e E f F))->tag eq qq(E); #TlastIn
ok $a->lastIn(qw(e E f F))->prevIn(qw(A G))->tag eq qq(A); #TprevIn
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($d, $c, $b, $f, $e) = $a->byList; #TisOnlyChild #TisOnlyChildToDepth #TisEmpty #TisFirstToDepth #TisLastToDepth
ok $d->parent->isOnlyChild;
ok $d->isOnlyChild; #TisOnlyChild
ok $d->isOnlyChild(qw(d c));
ok $d->isOnlyChild(qw(d c b));
ok $d->isOnlyChild(qw(d c b a));
ok !$d->isOnlyChild(qw(b)); #TisOnlyChild
ok $d->isOnlyChildToDepth(1, qw(d c b a)); #TisOnlyChildToDepth
ok $d->isOnlyChildToDepth(2, qw(d c b a)); #TisOnlyChildToDepth
ok !$d->isOnlyChildToDepth(3, qw(d c b a)); #TisOnlyChildToDepth
ok $d->isEmpty; #TisEmpty
ok $d->isFirstToDepth(4); #TisFirstToDepth
ok !$f->isFirstToDepth(2); #TisFirstToDepth
ok $f->isFirstToDepth(1); #TisFirstToDepth
ok !$f->isFirstToDepth(3); #TisFirstToDepth
ok $c->isLastToDepth(1); #TisLastToDepth
ok !$c->isLastToDepth(3); #TisLastToDepth
ok $d->isLastToDepth(2); #TisLastToDepth
ok !$d->isLastToDepth(4); #TisLastToDepth
}
#if (1) # Operators
# {my $a = Data::Edit::Xml::new("");
# my $b = $a >= [qw(b)]; ok $b->id == 2;
# my $c = $b >= [qw(c)]; ok $c->id == 3;
#
# ok $c <= [qw(c b a)];
# $a x= sub {ok $_->id == 3 if $_ <= [qw(c b a)]};
#
# my $A = $a >> \'\';
# ok -s $A eq \'\';
# ok -s $a eq \'\';
#
# my $B = $b > \'\';
# ok -s $B eq \'\';
# ok -s $a eq \'\';
#
# my $C = $b < \'\';
# ok -s $C eq \'\';
# ok -s $a eq \'\';
#
# my $D = $b << qq();
# ok -s $D eq \'\';
# ok -s $a eq \'\'; Trenew
# my $x = $a->renew; Trenew
# ok -s $a eq \'\'; Trenew
# ok 4 == grep{$_ <= [qw(b a)] } @$x;
# ok $a % \'id\' == 1;
# ok $b % \'id\' == 2;
# ok $c % \'id\' == 3;
# $a += qq(aa);
# ok -t $a eq \'aa\';
# my $e = $a / qq(ee);
# ok -s $e eq \'\';
#
# my $f = $a * qq(f);
# ok -s $e eq \'\';
#
# --$c;
# ok -s $e eq \'\';
#
# ++$a;
# ok -s $e eq \'\';
# }
if (1) # Labels
{my $x = Data::Edit::Xml::new("");
ok $x->stringReplacingIdsWithLabels eq \'\'; #TaddLabels #TcountLabels #TgetLabels #TstringNode
my $b = $x->go(q(b)); #TaddLabels #TcountLabels #TgetLabels #TstringNode
my $c = $b->go(q(c));
ok $b->countLabels == 0; #TaddLabels #TcountLabels #TgetLabels
ok $c->countLabels == 0;
$b->addLabels(1..2); #TaddLabels #TcountLabels #TgetLabels #TstringNode
$b->addLabels(3..4); #TaddLabels #TcountLabels #TgetLabels #TstringNode
ok $x->stringReplacingIdsWithLabels eq \'\'; #TaddLabels #TgetLabels #TcopyLabels #TcountLabels #TstringNode
$b->numberTree; #TstringNode
ok -S $b eq "b(2) 0:1 1:2 2:3 3:4"; #TstringNode
ok $b->countLabels == 4; #TcountLabels
is_deeply [1..4], [$b->getLabels]; #TgetLabels
$b->copyLabels($c) for 1..2; #TcopyLabels
ok $x->stringReplacingIdsWithLabels eq \'\'; #TcopyLabels #TdeleteLabels
ok $b->countLabels == 4;
ok $c->countLabels == 4;
is_deeply [1..4], [$b->getLabels];
is_deeply [1..4], [$c->getLabels];
$b->deleteLabels(1,4) for 1..2; #TdeleteLabels
ok $x->stringReplacingIdsWithLabels eq \'\'; #TdeleteLabels #TmoveLabels
ok $b->countLabels == 2;
ok $c->countLabels == 4;
is_deeply [2..3], [$b->getLabels];
is_deeply [1..4], [$c->getLabels];
$b->moveLabels($c) for 1..2; #TmoveLabels
ok $x->stringReplacingIdsWithLabels eq \'\'; #TmoveLabels
ok $b->countLabels == 0;
ok $c->countLabels == 4;
is_deeply [], [$b->getLabels];
is_deeply [1..4], [$c->getLabels];
ok -s $x eq \'\';
$c->id = 11;
ok -s $x eq \'\';
ok $x->stringReplacingIdsWithLabels eq \'\';
ok -p $x eq <
END
$x->go(qw(b c))->wrapWith(qw(C id 1)); #TwrapWith
ok -p $x eq <
END
$c->wrapContentWith(qw(D id 2)); # WrapContentWIth
ok -s $x eq \'\';
$c->wrapContentWith(qw(E id 3));
ok -s $x eq \'\';
ok $x->stringReplacingIdsWithLabels eq \'\';
$c->wrapUp(qw(A B)); # WrapUp
ok -s $x eq \'\';
$c->wrapDown(qw(G F)); # WrapDown
ok -s $x eq \'\';
}
if (1)
{my $x = Data::Edit::Xml::new("");
my $b = $x->go(q(b));
my $c = $x->go(qw(b c));
ok $x->stringReplacingIdsWithLabels eq \'\'; #TstringReplacingIdsWithLabels
$b->addLabels(1..4); #TstringReplacingIdsWithLabels
$c->addLabels(5..8); #TstringReplacingIdsWithLabels
ok $x->stringReplacingIdsWithLabels eq \'\'; #TstringReplacingIdsWithLabels
my $s = $x->stringReplacingIdsWithLabels; #TstringReplacingIdsWithLabels
ok $s eq \'\'; #TstringReplacingIdsWithLabels
$b->deleteLabels;
$c->deleteLabels;
ok $x->stringReplacingIdsWithLabels eq \'\';
}
if (1) # X versions
{my $x = Data::Edit::Xml::new("");
ok -p $x eq <
END
$x->go(q(b))->wrapContentWith(qw(D id DD)); #TwrapContentWith
ok -p $x eq <
END
}
if (1) # X versions
{my $a = Data::Edit::Xml::new(<
END
ok -p $a eq <
END
my ($b, $e, $f) = $a->firstBy(qw(b e f));
ok $b->id == 1;
ok $e->id == 6;
ok $f->id == 10;
ok $b->nextOn(qw(c)) ->id == 2;
ok $b->nextOn(qw(c d))->id == 5;
ok \'1 2 3 4 5\' eq join \' \', map {$_->id} $b->nextOn(qw(b c d));
ok $e->prevOn(qw(b c d))->id == 1;
ok \'6 5 4 3 2 1\' eq join \' \', map {$_->id} $e->prevOn(qw(b c d));
ok \'6 5 4 3 2\' eq join \' \', map {$_->id} $e->prevOn(qw( c d));
}
if (0) # X versions
{my $a = Data::Edit::Xml::new("");
eval
{my $c = $a->go(qw(b c));
my $d = $a->goX(qw(b c d));
ok 0;
};
}
if (1)
{my $a = Data::Edit::Xml::new(<
Diagnose the problem
This can be quite difficult
Sometimes impossible
ls -la
drwxr-xr-x 2 phil phil 4096 Jun 15 2016 Desktop
drwxr-xr-x 2 phil phil 4096 Nov 9 20:26 Downloads
END
# Transform to Dita step 1
$a->by(sub
{my ($o, $p) = @_;
if ($o->at(qw(pre p li sli)) and $o->isOnlyChild)
{$o->change($p->isFirst ? qw(cmd) : qw(stepresult));
$p->unwrap;
}
elsif ($o->at(qw(li sli)) and $o->over(qr(\\Ap( p)+\\Z)))
{$_->change($_->isFirst ? qw(cmd) : qw(info)) for $o->contents;
}
});
# Transform to Dita step 2
$a->by(sub
{my ($o) = @_;
$o->change(qw(step)) if $o->at(qw(li sli));
$o->change(qw(steps)) if $o->at(qw(sli));
$o->id = \'s\'.($o->position+1) if $o->at(qw(step));
$o->id = \'i\'.($o->index+1) if $o->at(qw(info));
$o->wrapWith(qw(screen)) if $o->at(qw(CDATA stepresult));
});
# Print the results
is_deeply [split //, (-p $a) =~ s/\\s+//gsr], [split //, <
Diagnose the problem
This can be quite difficult
Sometimes impossible
ls -la
drwxr-xr-x 2 phil phil 4096 Jun 15 2016 Desktop
drwxr-xr-x 2 phil phil 4096 Nov 9 20:26 Downloads
END
}
if (1) # Delete in context - methods
{my $a = Data::Edit::Xml::new q();
ok -s $a -> by(sub {$_ -> cut(qw(c b a))}) eq
\'\';
}
if (1) # Delete in context - methods
{my $a = Data::Edit::Xml::new q();
ok -s $a -> by(sub {$_ -> cut_c_b_a}) eq
\'\';
}
if (1) # Delete in context - chaining
{my $a = Data::Edit::Xml::new("");
$a->go_b_c__cut;
ok -s $a eq
\'\';
}
if (1) # Delete in context - operators
{my $a = Data::Edit::Xml::new("");
ok -s ($a x sub {--$_ if $_ <= [qw(c b a)]}) eq
\'\';
}
if (1) # Delete in context - operators
{my $a = Data::Edit::Xml::new("");
ok -s ($a x sub{$_->cut_c_b_a}) eq
\'\';
}
if (1) # Delete in context - exit chaining
{my $a = Data::Edit::Xml::new("");
ok -s $a->byX(sub {$_->at(qw(c b a))->cut}) eq
\'\';
}
if (1) # Delete in context - exit chaining
{my $a = Data::Edit::Xml::new("");
$a->byX(sub {die "found: c\\n" if $_->at(qw(c b a))});
ok $@ =~ m(\\Afound: c)s
}
if (1) # Delete in context - exit chaining
{my $a = Data::Edit::Xml::new(<
• Minimum 1 number
• No leading, trailing, or embedded spaces
• Not case-sensitive
END
$a->by(sub # Bulleted list to
{if ($_->at(qw(p))) #
{if (my $t = $_->containsSingleText) #
with single text
{if ($t->text =~ s(\\A\\x{2022}\\s*) ()s) # Starting with a bullet
{$_->change(qw(li)); #
to
-
if (my $p = $_->prev(qw(ul))) # Previous element is ul?
{$p->putLast($_->cut); # Put in preceding list or create a new list
}
else
{$_->wrapWith(qw(ul))
}
}
}
}
});
ok -p $a eq <
- Minimum 1 number
- No leading, trailing, or embedded spaces
- Not case-sensitive
END
}
if (1) # Bulleted list to
END
}
if (1)
{my $x = Data::Edit::Xml::new(<
END
my ($a, $b, $c) = $x->contents; #TcopyAttrs #TmoveAttrs
$a->copyAttrs($b, qw(aa bb)); #TcopyAttrs
ok <
END
$a->copyAttrs($b); #TcopyAttrs
ok <
END
$a->moveAttrs($c, qw(aa bb)); #TmoveAttrs
ok <
END
$b->moveAttrs($c); #TmoveAttrs
ok <
END
}
if (1)
{my $x = Data::Edit::Xml::new(<
END
my ($a, $b, $c) = $x->contents; #TcopyNewAttrs #TmoveNewAttrs
$a->copyNewAttrs($b, qw(aa bb)); #TcopyNewAttrs
ok <
END
$a->copyNewAttrs($b); #TcopyNewAttrs
ok <
END
$b->moveNewAttrs($c, qw(aa bb)); #TmoveNewAttrs
ok <
END
$b->moveNewAttrs($c); #TmoveNewAttrs
ok <
END
$a->swap($c); #Tswap
ok <
END
}
if (1)
{my $x = Data::Edit::Xml::new(<
aaa
bbb
ccc
ddd
eee
END
my $a = $x->first; #TisFirstText
my ($ta, $b, $tc, $d, $te) = $a->contents; #TisFirstText
ok $ta ->isFirstText(qw(a x)); #TisFirstText
ok $b->first->isFirstText(qw(b a x)); #TisFirstText
ok $b->prev ->isFirstText(qw(a x)); #TisFirstText
ok $d->last ->isFirstText(qw(d a x)); #TisFirstText
ok $d->next ->isLastText (qw(a x)); #TisLastText
ok $d->last ->isLastText (qw(d a x)); #TisLastText
ok $te ->isLastText (qw(a x)); #TisLastText
}
if (1)
{my $x = Data::Edit::Xml::new(<
aaa
bbb
ccc
ddd
eee
END
ok !$x->diff($x); #Tdiff
my $y = $x->clone; #Tdiff #Tclone
ok !$x->diff($y); #Tdiff #Tclone
$y->first->putLast($x->newTag(q(f))); #Tdiff
ok nws(<
aaa
bbb
ccc
ddd
eee
END
is_deeply [$x->diff($y)], ["ddd eee <", "/a>", "f/>"]; #Tdiff
is_deeply [diff(-p $x, $y)], ["ddd eee <", "/a>", "f/>"]; #Tdiff
is_deeply [$x->diff(-p $y)], ["ddd eee <", "/a>", "f/>"]; #Tdiff
my $X = writeFile(undef, -p $x); #Tdiff
my $Y = writeFile(undef, -p $y); #Tdiff
is_deeply [diff($X, $Y)], ["ddd eee <", "/a>", "f/>"]; #Tdiff
unlink $X, $Y;
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($b, $c, $d) = $a->contents; #Tdata
$c->data->{transform} = 1; #Tdata
ok <
END
$a x= sub #Tdata
{$_->cut if $_->data->{transform};
};
ok <
END
}
ok xmlHeader("") eq <
END
if (1)
{my $a = Data::Edit::Xml::new(""); #Tcrc
my ($b) = $a->contents; #Tcrc
changeReasonCommentSelectionSpecification = {ccc=>1, ddd=>1}; #Tcrc #TchangeReasonCommentSelectionSpecification
$b->putFirst(my $c = $b->newTag(q(c))); #Tcrc
$c->crc($_) for qw(aaa ccc); #Tcrc
ok <
END
changeReasonCommentSelectionSpecification = undef; #Tcrc #TchangeReasonCommentSelectionSpecification
$c->putFirst(my $d = $c->newTag(q(d))); #Tcrc
$d->crc($_) for qw(aaa ccc); #Tcrc
ok <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
ccc
END
my ($b) = $a->contents; #TrequiredCleanUp
$b->requiredCleanUp(q(33)); #TrequiredCleanUp
ok -p $a eq <
<b>
<c>
ccc
</c>
</b>
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($b) = $a->contents; #TreplaceWithRequiredCleanUp
$b->replaceWithRequiredCleanUp(q(bb)); #TreplaceWithRequiredCleanUp
ok -p $a eq <
bb
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->go(qw(b c d))->unwrapParentsWithSingleChild; #TunwrapParentsWithSingleChild
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->putFirstRequiredCleanUp(qq(1111\\n)); #TputFirstRequiredCleanUp
ok -p $a eq <
1111
END
$a->putLastRequiredCleanUp(qq(4444\\n)); #TputLastRequiredCleanUp
ok -p $a eq <
1111
4444
END
$a->go(q(b))->putNextRequiredCleanUp(qq(3333\\n)); #TputNextRequiredCleanUp
ok -p $a eq <
1111
3333
4444
END
$a->go(q(b))->putPrevRequiredCleanUp(qq(2222\\n)); #TputPrevRequiredCleanUp
ok -p $a eq <
1111
2222
3333
4444
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->first->invert; #Tinvert
ok -p $a eq <
END
$a->first->invert; #Tinvert
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->first->invertFirst;
ok -p $a eq <
END
$a->first->invertLast;
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $b) = $a->byList; #TmergeDuplicateChildWithParent #ThasSingleChild
is_deeply [$b->id, $c->id], [qw(b c)]; #TmergeDuplicateChildWithParent #ThasSingleChild
ok $c == $b->hasSingleChild; #TmergeDuplicateChildWithParent #ThasSingleChild
$b->mergeDuplicateChildWithParent; #TmergeDuplicateChildWithParent
ok -p $a eq <
END
ok $b == $a->hasSingleChild; #TmergeDuplicateChildWithParent #ThasSingleChild
}
# Dita tests
if (1)
{my $a = Data::Edit::Xml::new(<
- aaa
- bbb
END
$a->ditaObviousChanges; #TditaObviousChanges
ok -p $a eq <
-
aaa
-
bbb
END
$a->first->ditaListToSteps; #TditaListToSteps
ok -p $a eq <
aaa
bbb
END
$a->first->ditaStepsToList; #TditaStepsToList
ok -p $a eq <
- aaa
- bbb
END
$a->first->ditaListToStepsUnordered; #TditaListToStepsUnordered
ok -p $a eq <
aaa
bbb
END
ok Data::Edit::Xml::new(q())->ditaTopicHeaders eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
- aaa
- bbb
END
$a->first->ditaListToSubSteps; #TditaListToSubSteps
ok -p $a eq <
aaa
bbb
END
}
if (1)
{my $x = Data::Edit::Xml::new(<
h1
H1
h2
H2
h3
H3
h3
H3
h2
H2
h4
H4
END
my %file;
$x->htmlHeadersToSections; #ThtmlHeadersToSections #TdivideDocumentIntoSections
$x->divideDocumentIntoSections(sub #ThtmlHeadersToSections #TdivideDocumentIntoSections
{my ($topicref, $section) = @_; #ThtmlHeadersToSections #TdivideDocumentIntoSections
my $file = keys %file; #ThtmlHeadersToSections #TdivideDocumentIntoSections
$topicref->href = $file; #ThtmlHeadersToSections #TdivideDocumentIntoSections
$file{$file} = -p $section; #ThtmlHeadersToSections #TdivideDocumentIntoSections
$section->cut; #ThtmlHeadersToSections #TdivideDocumentIntoSections
}); #ThtmlHeadersToSections #TdivideDocumentIntoSections
ok -p $x eq <
END
ok nn(dump({map {$_=>nn($file{$_})} keys %file})) eq nn(dump( #ThtmlHeadersToSections #TdivideDocumentIntoSections
{"0" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
"1" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
"2" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
"3" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
"4" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
"5" => "N", #ThtmlHeadersToSections #TdivideDocumentIntoSections
}));
}
if (1)
{my $a = Data::Edit::Xml::new(<A
B
D
E
F
G
H
END
$a->numberTreesJustIds(q(T)); #TnumberTreesJustIds
my $A = Data::Edit::Xml::new(<A
B
D
E
F
G
H
END
ok -p $a eq -p $A; #TnumberTreesJustIds
}
if (1)
{my $a = Data::Edit::Xml::new(<Hello World
END
$a->first->changeText(sub{s(l) (L)g}); #TchangeText
ok -s $a eq q(HeLLo WorLd); #TchangeText
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $i = $a->indexIds; #TindexIds
ok $i->{C}->tag eq q(c); #TindexIds
ok $i->{E}->tag eq q(e); #TindexIds
}
if (1)
{my $a = Data::Edit::Xml::new(<Aaaaa
Bbbbb
Ccccc
Ddddd
Eeeee
Fffff
Ggggg
Hhhhhh
END
my $A = Data::Edit::Xml::new(<AaaAaaA
BbbBbbB
Ccccc
DddDddD
EeeEeeE
FffFffF
GggGggG
Hhhhhh
END
$a->numberTreesJustIds(q(a)); #TcreatePatch #TData::Edit::Xml::Patch::install
$A->numberTreesJustIds(q(a)); #TcreatePatch #TData::Edit::Xml::Patch::install
my $patches = $a->createPatch($A); #TcreatePatch #TData::Edit::Xml::Patch::install
$patches->install($a); #TcreatePatch #TData::Edit::Xml::Patch::install
ok !$a->diff ($A); #TcreatePatch #TData::Edit::Xml::Patch::install
ok $a->equals($A); #TcreatePatch #TData::Edit::Xml::Patch::install
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $e, $f, $d, $b) = $a->byList; #TupThru
ok -t $f eq q(f); #TupThru
ok -t $f->upThru eq q(f); #TupThru
ok -t $f->upThru(qw(d)) eq q(d); #TupThru
ok -t eval{$f->upThru(qw(d))->last->prev} eq q(e); #TupThru
ok ! eval{$f->upThru(qw(d b))->next}; #TupThru
}
if (1)
{my $a = Data::Edit::Xml::newTree(q(a)); #TaddFirst
$a->addFirst(qw(b id b)) for 1..2; #TaddFirst
ok -p $a eq <
END
$a->addLast(qw(e id e)) for 1..2; #TaddLast
ok -p $a eq <
END
$a->addFirst(qw(b id B))->addNext(qw(c id c)); #TaddNext
ok -p $a eq <
END
$a->addLast(qw(e id E))->addPrev(qw(d id d)); #TaddPrev
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TaddWrapWith
my $b = $a->first; #TaddWrapWith
$b->addWrapWith(qw(c id c)) for 1..2; #TaddWrapWith
ok -p $a eq <
END
$a->addSingleChild(q(d)) for 1..2; #TaddSingleChild
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::newTree(q(a)); #TaddFirstAsText
$a->addFirstAsText(q(aaaa)) for 1..2; #TaddFirstAsText
ok -s $a eq q(aaaa); #TaddFirstAsText #TaddLastAsText
$a->addLastAsText(q(dddd)) for 1..2; #TaddLastAsText
ok -s $a eq q(aaaadddd); #TaddLastAsText
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TaddNextAsText
$a->go(q(b))->addNextAsText(q(bbbb)) for 1..2; #TaddNextAsText
ok -p $a eq <
bbbb
END
$a->go(q(b))->addPrevAsText(q(aaaa)) for 1..2; #TaddPrevAsText
ok -p $a eq <aaaa
bbbb
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
Note: see over for details.
END
$a->ditaParagraphToNote(1); #TditaParagraphToNote
ok -p $a eq <
See over for details.
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->propagate(q(b)); #Tpropagate
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TwrapSiblingsBefore
my ($b, $c, $d) = $a->byList; #TwrapSiblingsBefore
$c->wrapSiblingsBefore(q(X)); #TwrapSiblingsBefore
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TwrapSiblingsAfter
my ($b, $c, $d) = $a->byList; #TwrapSiblingsAfter
$c->wrapSiblingsAfter(q(Y)); #TwrapSiblingsAfter
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TwrapSiblingsBetween
my ($b, $c, $d) = $a->byList; #TwrapSiblingsBetween
$b->wrapSiblingsBetween($d, q(Y)); #TwrapSiblingsBetween
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $styles = $a->wordStyles; #TwordStyles
is_deeply $styles, {bulletedList=>{aa=>{2=>1}}}; #TwordStyles
}
if (1)
{my $a = Data::Edit::Xml::new(<
Month |
Savings |
Phone |
Comment |
January |
100 |
555-1212 |
February |
80 |
END
$a->htmlTableToDita; #ThtmlTableToDita
ok -p $a eq <
Month
Savings
Phone
Comment
January
100
555-1212
February
80
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $e = $a->go(qw(b -1 e)); #TforestNumberTrees
$e->forestNumberTrees(1); #TforestNumberTrees
ok -p $a eq <
END
my $b = $e->findByForestNumber(1, 2);
is_deeply [$b->getLabels], ["b"];
my $B = $e->findByForestNumber(1, 4); #TfindByForestNumber
is_deeply [$B->getLabels], ["B"]; #TfindByForestNumber
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
if (1) {
my ($good, $fail, $possible) = $a->goFish(qw(b c D)); #TgoFish
ok $fail eq q(D); #TgoFish
is_deeply $good, [qw(b c)]; #TgoFish
is_deeply $possible, [q(d)]; #TgoFish
}
if (1)
{my ($good, $fail, $possible) = $a->goFish(qw(b 3));
ok $fail eq q(3);
is_deeply $good, [q(b)];
is_deeply $possible, [0..2];
}
if (1)
{my ($good, $fail, $possible) = $a->goFish(qw(b 0 c D));
ok $fail eq q(D);
is_deeply $good, [qw(b 0 c)];
is_deeply $possible, [qw(d)];
}
if (1)
{my ($g, $f, $p) = $a->goFish(qw(b c d));
is_deeply $g, [qw(b c d)];
ok !$f;
ok !$p;
}
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($d, $c, $b, $C, $B, $f, $e) = $a->byList; #TisFirst #TisLast #TisOnlyChild #ThowFirst #ThowLast #ThowOnlyChild #ThowFarAbove #ThowFarBelow #ThowFar #Tadjacent #TcommonAdjacentAncestors
is_deeply [$d->commonAdjacentAncestors($C)], [$b, $B]; #TcommonAdjacentAncestors #ThowFar
ok $d->howFar($d) == 0; #ThowFar
ok $d->howFar($a) == 3; #ThowFar
ok $b->howFar($B) == 1; #ThowFar
ok $d->howFar($f) == 5; #ThowFar
ok $d->howFar($C) == 4; #ThowFar
ok $a->isFirst; #TisFirst
ok $a->isLast; #TisLast
ok $a->isOnlyChild; #TisOnlyChild
ok !$a->adjacent($B); #Tadjacent
ok $b->adjacent($B); #Tadjacent
ok $d->howFirst == 4; #ThowFirst
ok $f->howLast == 3; #ThowLast
ok $d->howOnlyChild == 2; #ThowOnlyChild
ok $a->howFarAbove($d) == 3; #ThowFarAbove
ok !$d->howFarAbove($c); #ThowFarAbove
ok $d->howFarBelow($a) == 3; #ThowFarBelow
ok !$c->howFarBelow($d); #ThowFarBelow
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
ok $a->first->not_a_c; #Tnot
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $b) = $a->byList; #TAUTOLOAD
ok $c->at_c_b_a; #TAUTOLOAD
ok !$c->at_b; #TAUTOLOAD
ok -t $c->change_d_c_b eq q(d); #TAUTOLOAD
ok ! $c->change_d_b; #TAUTOLOAD
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a x= sub{$_->ditaMergeLists}; #TditaMergeLists
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(q()); #TcountAttrNamesOnTagExcluding
ok $a->countAttrNamesOnTagExcluding_a_b == 3;
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList; #Tapn #Tap #Tan #TupWhileFirst #TupUntilFirst #TupWhileLast #TupUntilLast #TupWhileIsOnlyChild #TupUntilIsOnlyChild #TdownWhileFirst #TdownWhileLast #TdownWhileSingleChild #ThasSingleChildToDepth
ok $h == $g->hasSingleChildToDepth(1); #ThasSingleChildToDepth
ok $i == $g->hasSingleChildToDepth(2); #ThasSingleChildToDepth
ok !$g->hasSingleChildToDepth(0); #ThasSingleChildToDepth
ok !$g->hasSingleChildToDepth(3); #ThasSingleChildToDepth
ok $i == $i->hasSingleChildToDepth(0); #ThasSingleChildToDepth
ok $h == $g->downWhileHasSingleChild; #TdownWhileHasSingleChild
ok $h == $h->downWhileHasSingleChild; #TdownWhileHasSingleChild
ok !$i->downWhileHasSingleChild; #TdownWhileHasSingleChild
ok $k == $g->downWhileFirst; #TdownWhileFirst
ok $c == $a->downWhileFirst; #TdownWhileFirst
ok $c == $c->downWhileFirst; #TdownWhileFirst
ok !$d->downWhileFirst; #TdownWhileFirst
ok $l == $a->downWhileLast; #TdownWhileLast
ok $l == $g->downWhileLast; #TdownWhileLast
ok !$d->downWhileLast; #TdownWhileLast
ok $h == $i->upWhileIsOnlyChild; #TupWhileIsOnlyChild
ok $j == $j->upWhileIsOnlyChild; #TupWhileIsOnlyChild
ok !$d->upWhileIsOnlyChild; #TupWhileIsOnlyChild
ok $i == $k->upUntilIsOnlyChild; #TupUntilIsOnlyChild
is_deeply[$c, $e], [$d->apn_c_d_e_b_a]; #Tapn
ok $c == $d->ap_d_c_b_a; #Tap
ok $c == $d->ap_d; #Tap
ok !$c->ap_c; #Tap
ok $e == $d->an_d_e_b_a; #Tan
ok $f == $e->an_e; #Tan
ok !$f->an_f; #Tan
ok $h == $i->upWhileFirst; #TupWhileFirst
ok $a == $c->upWhileFirst; #TupWhileFirst
ok !$d->upWhileFirst; #TupWhileFirst
ok $b == $d->upUntilFirst; #TupUntilFirst
ok $j == $j->upWhileLast; #TupWhileLast
ok $a == $l->upWhileLast; #TupWhileLast
ok !$d->upWhileLast; #TupWhileLast
ok $i == $k->upUntilLast; #TupWhileLast
ok $j->childOf($e); #TchildOf
ok $e->parentOf($j); #TparentOf
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TputFirstCut
$c->putFirstCut($d, qw(c b a)); #TputFirstCut
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TputLastCut
$a->putLastCut($d, qw(a)); #TputLastCut
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TputNextCut
$d->putNextCut($c, qw(d b a)); #TputNextCut
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TputPrevCut
$c->putPrevCut($d, qw(c b a)); #TputPrevCut
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TopWrapContentWith
$b *= q(B); #TopWrapContentWith
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b) = $a->byList; #TopUnwrap
$b++; #TopUnwrap
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $A = Data::Edit::Xml::new(<
END
ok !$a->equals($A); #TequalsIgnoringAttributes
ok !$a->equalsIgnoringAttributes($A, qw(id)); #TequalsIgnoringAttributes
ok $a->equalsIgnoringAttributes($A, qw(id outputclass)); #TequalsIgnoringAttributes
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my $A = Data::Edit::Xml::new(<
END
my $N = 0; $a->by(sub{$_->addLabels((-t $_).++$N)}); #TstringExtendingIdsWithLabels
ok -p (new $a->stringExtendingIdsWithLabels) eq <
END
ok -p (new $A->stringExtendingIdsWithLabels) eq <
END
ok $a->copyLabelsAndIdsInTree($A) == 10; #TcopyLabelsAndIdsInTree
ok -p (new $A->stringExtendingIdsWithLabels) eq <
END
is_deeply [sort keys %{$A->labelsInTree}], #TlabelsInTree
["B", "C", "a", "a5", "b", "b2", "b4", "c", "c1", "c3"]; #TlabelsInTree
}
if (1) #TmatchTree
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b, $g, $f, $e) = $a->byList;
is_deeply [$b, $c, $d], [$b->matchTree(qw(b c d))];
is_deeply [$e, $f, $g], [$e->matchTree(qr(\\Ae\\Z), [qw(f g)])];
is_deeply [$c], [$c->matchTree(qw(c))];
is_deeply [$a, $b, $c, $d, $e, $f, $g],
[$a->matchTree({a=>1}, [qw(b c d)], [qw(e), [qw(f g)]])];
}
if (1) #Toat #Toft #Tolt
{my $a = Data::Edit::Xml::new(<
END
my ($c, $d, $b, $g, $f, $e) = $a->byList;
ok $b->oat_c_d;
ok $a->oat_b_e;
ok $g->oat;
ok !$b->oat_d;
ok $a->oft_b;
ok $b->oft_c;
ok $f->oft_g;
ok $g->oft;
ok !$b->oft_d;
ok $a->olt_e;
ok $b->olt_d;
ok $f->olt_g;
ok $g->olt;
ok !$b->olt_c;
}
if (1) #Tmpt #Tmnt
{my $a = Data::Edit::Xml::new(<
END
my ($b, $c, $d, $e, $f, $g) = $a->contents;
ok $f->mpt_e_d_c;
ok !$f->mpt_e_d_b;
ok $c->mnt_d_e_f;
ok !$c->mnt_e;
}
if (1) #ToverAllTags #ToverFirstTags #ToverLastTags
{my $a = Data::Edit::Xml::new(<
END
ok $a->overAllTags_b_c_d;
ok !$a->overAllTags_b_c;
ok !$a->overAllTags_b_c_d_e;
ok $a->oat_b_c_d;
ok !$a->oat_B_c_d;
ok $a->overFirstTags_b_c_d;
ok $a->overFirstTags_b_c;
ok !$a->overFirstTags_b_c_d_e;
ok $a->oft_b_c;
ok !$a->oft_B_c;
ok $a->overLastTags_b_c_d;
ok $a->overLastTags_c_d;
ok !$a->overLastTags_b_c_d_e;
ok $a->olt_c_d;
ok !$a->olt_C_d;
}
if (1)
{my $a = Data::Edit::Xml::new(<
bbccBB
END
my ($bb, $cc, $c, $BB, $b) = $a->byList; #TfirstTextMatches #TlastTextMatches
ok $bb->matchesText(qr(bb)); #TfirstTextMatches
ok $b->at_b_a && $b->firstTextMatches(qr(bb)); #TfirstTextMatches
ok $b->firstTextMatches(qr(bb), qw(b a)); #TfirstTextMatches
ok $c->at_c_b && $c->firstTextMatches(qr(cc)); #TfirstTextMatches
ok $c->at_c_b && !$c->firstTextMatches(qr(bb)); #TfirstTextMatches
ok $BB->matchesText(qr(BB)); #TlastTextMatches
ok $b->at_b_a && $b->lastTextMatches(qr(BB)); #TlastTextMatches
ok $b->lastTextMatches(qr(BB), qw(b a)); #TlastTextMatches
ok $c->at_c_b && $c->lastTextMatches(qr(cc)); #TlastTextMatches
ok $c->at_c_b && !$c->lastTextMatches(qr(bb)); #TlastTextMatches
ok $cc->matchesText(qr(cc)); #TnextTextMatches #TprevTextMatches
ok $c->at_c_b && $c->prevTextMatches(qr(bb)); #TprevTextMatches
ok $c->at_c_b && $c->nextTextMatches(qr(BB)); #TnextTextMatches
ok $b->at_b && !$b->prevTextMatches(qr(bb)); #TprevTextMatches
ok $b->at_b && !$b->nextTextMatches(qr(BB)); #TnextTextMatches
$b->deleteContent; #TdeleteContent
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
bbb.
ccc.
END
ok nn(-p $a) eq qq(N bbb.NN N ccc.NNNN); #TprettyString
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->changeAttributeValue(q(aa), sub{s(b) (B)}); #TchangeAttributeValue
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
Data::Edit::Xml::ditaOrganization = q(ACT); #TditaOrganization #TprettyStringDitaHeaders #TopString
ok $a->prettyStringDitaHeaders eq <
END
ok -x $a eq <
END
}
if (1) #Tupn
{my $a = Data::Edit::Xml::new(<
END
my ($e, $d, $c, $b) = $a->byList; #Tupn
ok $e = $e->upn_0_e_d_c_b_a; #Tupn
ok $d = $e->upn_1_d_c_b_a; #Tupn
ok $c = $e->upn_2_c_b_a; #Tupn
ok $b = $e->upn_3_b_a; #Tupn
ok $a = $e->upn_4_a; #Tupn
ok !$e->upn_5; #Tupn
is_deeply [$e, $d, $c, $b, $a], [$e->ancestry];
}
if (1) #Tattributes
{my $a = Data::Edit::Xml::new(q());
$a->id = q(id);
ok $a->id eq q(id);
ok !defined($a->href);
ok $a->hrefX eq q();
ok -s $a eq q();
$a->href = q(href);
ok $a->href eq q(href);
ok $a->hrefX eq q(href);
ok -s $a eq q();
$a->href = undef;
ok !defined($a->href);
ok $a->hrefX eq q();
ok -s $a eq q();
}
if (1) #TditaMaximumNumberOfEntriesInARow #TditaAddColSpecToTgroup
{my $a = Data::Edit::Xml::new(<
END
ok 3 == $a->ditaMaximumNumberOfEntriesInARow;
$a->first->ditaAddColSpecToTgroup(3);
ok -p $a eq <
END
}
if (1) #TditaFixTableColSpec
{my $a = Data::Edit::Xml::new(<
END
$a->ditaFixTableColSpec;
ok -p $a eq <
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($b, $c, $d, $e, $f) = $a->byList; #TfirstNot #TlastNot #TnextNot #TprevNot #TnextWhile #TprevWhile #TnextUntil #TprevUntil
ok $c == $a->firstNot_a_b; #TfirstNot
ok $d == $a->lastNot_e_f; #TlastNot
ok $e == $b->nextWhile_c_d; #TnextWhile
ok $c == $f->prevWhile_e_d; #TprevWhile
ok $c == $b->nextWhile; #TnextWhile
ok $b == $c->prevWhile; #TprevWhile
ok $e == $b->nextUntil_e_f; #TnextUntil
ok $b == $f->prevUntil_a_b; #TprevUntil
ok !$b->nextUntil; #TnextUntil
ok !$c->prevUntil; #TprevUntil
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
my ($f, $e, $d, $c, $b, $F, $E, $D, $C, $B) = $a->byList; #TfirstWhile #TfirstUntil #TlastWhile #TlastUntil
if (1) #TfirstWhile #TfirstUntil
{ok $d == $a->firstWhile_a_d_c_b;
ok $f == $a->firstWhile_a_d_c_b_e_f_g_h;
ok !$b->firstWhile_a;
ok $e == $a->firstUntil_e_d;
ok !$c->firstUntil_c;
ok !$b->firstUntil_a;
}
if (1) #TlastWhile #TlastUntil
{ok $D == $a->lastWhile_a_D_C_B;
ok $F == $a->lastWhile_a_D_C_B_E_F_G_H;
ok !$B->lastWhile_a;
ok $E == $a->lastUntil_E_D;
ok !$C->lastUntil_C;
ok !$B->lastUntil_a;
}
}
if (1) #TAUTOLOAD
{my $a = Data::Edit::Xml::new(<
END
ok -t $a->first_b__first_c__next__next_e__next eq q(f);
ok !$a->first_b__first_c__next__next_f;
}
if (1) #TmatchesNextTags #TmatchesPrevTags
{my $a = Data::Edit::Xml::new(<
END
ok -t $a->first__first__matchesNextTags_d_e eq q(c);
ok -t $a->first__first__mnt_d_e eq q(c);
ok !$a-> first__matchesNextTags_d_e;
ok -t $a-> last->last__matchesPrevTags_e_d eq q(f);
ok -t $a-> last->last__mpt_e_d eq q(f);
ok !$a-> last__matchesPrevTags_e_d;
}
if (1) #Tfirstn #Tnextn
{my $a = Data::Edit::Xml::new(<
END
ok -p $a eq <
END
ok -t $a->firstn_0 eq q(a);
ok -t $a->firstn_1 eq q(b);
ok -t $a->firstn_2 eq q(c);
ok -t $a->firstn_3 eq q(d);
ok -t $a->firstn_3__nextn_0 eq q(d);
ok -t $a->firstn_3__nextn_1 eq q(e);
ok -t $a->firstn_3__nextn_2 eq q(f);
}
if (1) #Tlastn #Tprevn
{my $a = Data::Edit::Xml::new(<
END
ok -p $a eq <
END
ok -t $a->lastn_0 eq q(a);
ok -t $a->lastn_1 eq q(B);
ok -t $a->lastn_2 eq q(C);
ok -t $a->lastn_3 eq q(F);
ok -t $a->lastn_3__prevn_0 eq q(F);
ok -t $a->lastn_3__prevn_1 eq q(E);
ok -t $a->lastn_3__prevn_2 eq q(D);
}
if (!$windows) {
my $a = Data::Edit::Xml::new(q().(q(𝝱)x1e3).q()); #TwriteCompressedFile #TreadCompressedFile
my $file = $a->writeCompressedFile(q(zzz.xml.zip)); #TwriteCompressedFile #TreadCompressedFile
ok length(-s $a) eq 8007;
ok -e $file;
my $A = readCompressedFile($file); #TwriteCompressedFile #TreadCompressedFile
ok $a->equals($A); #TwriteCompressedFile #TreadCompressedFile
ok length(-s $a) == length(-s $A);
ok -t $a->firstn_0 eq q(a);
ok -t $a->firstn_1 eq q(b);
ok $a->firstn_2__text eq q(𝝱);
unlink $file;
}
else
{ok 1 for 1..7
}
if (1) #TditaPrettyPrintWithHeaders
{my $a = Data::Edit::Xml::new(q());
ok $a->ditaPrettyPrintWithHeaders eq <
END
}
if (1) # Command and attributes
{my $a = Data::Edit::Xml::new(<
END
my $n = 0;
$a->by(sub
{my ($o) = @_;
$o->id = ++$n % 2;
$o->class = $n % 3;
});
ok -p $a eq <
END
$a->by(sub
{my ($o) = @_;
ok $o->class == 2 if $o->atId_0_e;
ok $o->class == 0 if $o->atId_1_e_c_b;
ok !$o->atId_1_e_b;
});
$a->deleteAttrsInTree_class; #TdeleteAttrsInTree
ok -p $a eq <
END
}
if (1) #TattrX
{my $a = Data::Edit::Xml::new(q());
my $b = $a->first;
ok $b->attrX_name eq q(bb);
ok !$b->attrX_bbb;
}
if (1) #Tunwrap
{my $a = Data::Edit::Xml::new(q(aaa));
my $t = $a->first;
ok !$t->unwrap;
}
if (1)
{my $a = Data::Edit::Xml::new(<
±
END
}
if (1)
{my $a = Data::Edit::Xml::new(<
END
$a->numberTreesJustIds(q(i));
ok -p $a eq <
END
ok -t $a->findById_i4 eq q(B); #TfindById
ok -t $a->findById_i5 eq q(c); #TfindById
$a->wrapRuns(q(B)); #TwrapRuns
ok -p $a eq <
END
}
if (1) #TmatchesNode #TmatchesSubTree #TfindMatchingSubTrees
{my $a = Data::Edit::Xml::new(<
END
my ($c, $b, $C, $B) = $a->byList;
ok $b->id == 2;
ok $c->id == 3;
ok $B->id == 5;
ok $C->id == 6;
ok $c->matchesNode($C, qw(name));
ok !$c->matchesNode($C, qw(id name));
ok $c->matchesSubTree($C, qw(name));
ok $b->matchesSubTree($B, qw(name));
ok !$c->matchesSubTree($C, qw(id name));
ok !$b->matchesSubTree($C, qw(name));
is_deeply [$a->findMatchingSubTrees($b, qw(name))], [$b, $B];
is_deeply [$a->findMatchingSubTrees($c, qw(name))], [$c, $C];
is_deeply [$a->findMatchingSubTrees(new(q()))], [$c, $C];
is_deeply [$a->findMatchingSubTrees(new(q()))], [$b, $B];
is_deeply [$a->findMatchingSubTrees(new(q()), q(id))], [$b];
}
if (1) #TputFirstAsTree #TputLastAsTree #TputNextAsTree #TputPrevAsTree
{my $a = Data::Edit::Xml::new(q());
ok -p $a eq <
END
my $b = $a->putFirstAsTree(q());
ok -p $a eq <
END
$b->putNextAsTree(q());
ok -p $a eq <
END
my $e = $a->putLastAsTree(q());
ok -p $a eq <
END
$e->putPrevAsTree(q());
ok -p $a eq <
END
}
if (1) #TwrapFromFirst
{my $a = Data::Edit::Xml::new(q());
ok -p $a eq <
END
$a->go_c->wrapFromFirst_B;
ok -p $a eq <
END
}
if (1) #TwrapToLast
{my $a = Data::Edit::Xml::new(q());
ok -p $a eq <
END
$a->go_c->wrapToLast_D;
ok -p $a eq <
END
}
if (1) #Theight #Tdepth #TdepthProfile
{my $a = Data::Edit::Xml::new(q());
ok -p $a eq <
END
my ($d, $c, $e, $b) = $a->byList;
ok $a->height == 4;
ok $a->depth == 0;
ok $c->depth == 2;
ok $c->height == 2;
ok $e->depth == 2;
ok $e->height == 1;
is_deeply [$a->depthProfile], [qw(4 3 3 2 1)];
}
if (1) #TsetDepthProfile #TsetRepresentationAsTagsAndText #TsetRepresentationAsText #TdepthProfileLast #TrepresentationLast #TmatchNodesByRepresentation #TstringTagsAndText #TstringText
{my $a = Data::Edit::Xml::new(<
cc
dd
cc
dd
END
my $b = $a->first_b; my $B = $a->last_B;
my $c = $b->first_c; my $C = $B->first_c;
my $d = $c->first_d; my $D = $C->first_d;
$a->setDepthProfile;
ok $b->depthProfileLast eq q(3 3 3 2 1);
ok $b->depthProfileLast eq $B->depthProfileLast;
# Represent using tags and text
$a->setRepresentationAsTagsAndText;
is_deeply [$b->stringTagsAndText], [qw(cc d dd c b)];
is_deeply [$B->stringTagsAndText], [qw(cc d dd c B)];
ok $b->representationLast eq qq(cc d dd c b);
ok $B->representationLast eq qq(cc d dd c B);
ok $c->representationLast eq qq(cc d dd c);
ok $C->representationLast eq qq(cc d dd c);
ok dump($b->representationLast) ne dump($B->representationLast);
is_deeply $c->representationLast,
$C->representationLast;
my $m = $a->matchNodesByRepresentation;
my $bb = $b->representationLast;
is_deeply $m->{$bb}, [$b];
my $cc = $c->representationLast;
is_deeply $m->{$cc}, [$c, $C];
# Represent using just text
$a->setRepresentationAsText;
is_deeply [$b->stringText], [qw(cc dd)];
is_deeply [$B->stringText], [qw(cc dd)];
ok $b->representationLast eq qq(cc dd);
ok $B->representationLast eq qq(cc dd);
is_deeply $b->representationLast,
$B->representationLast;
is_deeply $c->representationLast,
$C->representationLast;
my $M = $a->matchNodesByRepresentation;
my $BB = $b->representationLast;
is_deeply $M->{$BB}, [$c, $b, $C, $B];
my $CC = $c->representationLast;
is_deeply $M->{$BB}, [$c, $b, $C, $B];
ok $b->representationLast eq $c->representationLast;
}
if (1) #TisOnlyChildText
{my $a = Data::Edit::Xml::new(q(aaaa));
ok $a->first->isOnlyChildText;
}
if (1) #TisOnlyChildBlankText
{my $a = Data::Edit::Xml::new(q(aaaa));
$a->first->text = q( );
ok $a->prettyStringCDATA eq qq( \\n);
ok $a->first->isOnlyChildBlankText;
ok !$a->isOnlyChildBlankText;
}
if (1) #TisOnlyChildBlankText
{my $a = Data::Edit::Xml::new(q());
my $b = $a->new(q());
ok -p $a eq qq(\\n);
ok -p $b eq qq(\\n);
}
if (1) #TattrValueAt
{my $a = Data::Edit::Xml::new(q());
my $b = $a->first;
ok !$b->attrValueAt_c_C_c_a;
ok $b->attrValueAt_c_C_b_a;
}
if (1) #TditaListToTable
{my $a = Data::Edit::Xml::new(<
-
1111
2222
3333
4444
-
aaaa1111
aaaa2222
aaaa3333
aaaa4444
-
bbbb1111
bbbb2222
bbbb3333
-
cccc1111
cccc2222
cccc3333
cccc4444
cccc5555
END
$a->ditaListToTable;
ok nws(-p $a) eq nws(<
1111
2222
3333
4444
aaaa1111
aaaa2222
aaaa3333
aaaa4444
bbbb1111
bbbb2222
bbbb3333
cccc1111
cccc2222
cccc3333
cccc4444
cccc5555
END
}
1
' called at lib/Data/Edit/Xml.pm line 19266
Data::Edit::Xml::test() called at test.pl line 10
# Looks like your test exited with 25 just after 127.
test.pl ..
1..1018
ok 1
ok 2
ok 3
ok 4
ok 5
ok 6
ok 7
ok 8
ok 9
ok 10
ok 11
ok 12
ok 13
ok 14
ok 15
ok 16
ok 17
ok 18
ok 19
ok 20
ok 21
ok 22
ok 23
ok 24
ok 25
ok 26
ok 27
ok 28
ok 29
ok 30
ok 31
ok 32
ok 33
ok 34
ok 35
ok 36
ok 37
ok 38
ok 39
ok 40
ok 41
ok 42
ok 43
ok 44
ok 45
ok 46
ok 47
ok 48
ok 49
ok 50
ok 51
ok 52
ok 53
ok 54
ok 55
ok 56
ok 57
ok 58
ok 59
ok 60
ok 61
ok 62
ok 63
ok 64
ok 65
ok 66
ok 67
ok 68
ok 69
ok 70
ok 71
ok 72
ok 73
ok 74
ok 75
ok 76
ok 77
ok 78
ok 79
ok 80
ok 81
ok 82
ok 83
ok 84
ok 85
ok 86
ok 87
ok 88
ok 89
ok 90
ok 91
ok 92
ok 93
ok 94
ok 95
ok 96
ok 97
ok 98
ok 99
ok 100
ok 101
ok 102
ok 103
ok 104
ok 105
ok 106
ok 107
ok 108
ok 109
ok 110
ok 111
ok 112
ok 113
ok 114
ok 115
ok 116
ok 117
ok 118
ok 119
ok 120
ok 121
ok 122
ok 123
ok 124
ok 125
ok 126
ok 127
Dubious, test returned 25 (wstat 6400, 0x1900)
Failed 891/1018 subtests
Test Summary Report
-------------------
test.pl (Wstat: 6400 Tests: 127 Failed: 0)
Non-zero exit status: 25
Parse errors: Bad plan. You planned 1018 tests but ran 127.
Files=1, Tests=127, 1 wallclock secs ( 0.02 usr 0.01 sys + 0.17 cusr 0.02 csys = 0.22 CPU)
Result: FAIL
Failed 1/1 test programs. 0/127 subtests failed.
PRBRENAN/Data-Edit-Xml-20181204.tar.gz
./Build test verbose=1 -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports PRBRENAN/Data-Edit-Xml-20181204.tar.gz
Finished 2018-12-05T02:00:53