File: set.t

package info (click to toggle)
libdata-stag-perl 0.14-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,480 kB
  • sloc: perl: 6,394; lisp: 141; xml: 116; ansic: 55; makefile: 17; sh: 2
file content (44 lines) | stat: -rw-r--r-- 1,189 bytes parent folder | download | duplicates (6)
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');