1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
|
use lib 't';
BEGIN {
# to handle systems with no installed Test module
# we include the t dir (where a copy of Test.pm is located)
# as a fallback
eval { require Test; };
use Test;
plan tests => 2;
}
use Data::Stag;
use strict;
my $s = Data::Stag->unflatten(people=>[
person=>{name=>'Sherlock Holmes',
job=>'detective'},
person=>{name=>'James Bond',
job=>'secret agent'},
],
);
print $s->xml;
my $orig = $s->d;
my $person;
my $address = Data::Stag->unflatten(address=>{
address_line=>"221B Baker Street",
city=>"London",
country=>"Great Britain",
});
($person) = $s->qmatch('person', (name => "Sherlock Holmes"));
$person->set("address", $address->data);
print $s->xml;
($person) = $s->qmatch('person', (job=>'detective'));
ok([$s->qmatch('person', (job=>'detective'))]->[0]->sget_address->get_city eq 'London');
$s = $orig;
($person) = $s->qmatch('person', (name => "Sherlock Holmes"));
#$person->set("address", $address->data);
$person->set(@$address);
print $s->xml;
ok([$s->qmatch('person', (job=>'detective'))]->[0]->sget_address->get_city eq 'London');
|