aboutsummaryrefslogtreecommitdiff
path: root/t/04-resource.t
blob: 05fd5b63d42725fb71361ea523fcb80c53a255af (plain)
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
#!/usr/bin/perl 
use strict;
use warnings;
use Test::More 'no_plan';
use Test::Exception;
 
BEGIN { use_ok('WebCoso::Resource'); }
 
my $r=WebCoso::Resource->new();
 
isa_ok($r,'WebCoso::Resource');
 
$r->set_property(prop1=>'value1');
is($r->get_property('prop1'),'value1','simple global');
is($r->get_property({},'prop1'),'value1','explicit global');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value1','over global');
 
$r->set_property(prop1=>'value2');
is($r->get_property('prop1'),'value2','simple global redef');
is($r->get_property({},'prop1'),'value2','explicit global redef');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value2','over global redef');
 
$r->set_property({},prop1=>'value3');
is($r->get_property('prop1'),'value3','simple global redef');
is($r->get_property({},'prop1'),'value3','explicit global redef');
is($r->get_property({a1=>1,a2=>3},'prop1'),'value3','over global redef');
 
$r->set_property({a1=>3},prop2=>'v1');
ok(! defined $r->get_property('prop2'),'undef on generalization');
is($r->get_property({a1=>3},'prop2'),'v1','specific');
is($r->get_property({a1=>3,a2=>3},'prop2'),'v1','over specific');
 
$r->set_property({a1=>2},prop2=>'v2');
ok(! defined $r->get_property('prop2'),'undef on generalization');
is($r->get_property({a1=>3},'prop2'),'v1','specific, oldval');
is($r->get_property({a1=>3,a2=>3},'prop2'),'v1','over specific, oldval');
is($r->get_property({a1=>2},'prop2'),'v2','specific, newval');
is($r->get_property({a1=>2,a2=>3},'prop2'),'v2','over specific, newval');
 
$r->set_property({a1=>1,a2=>2},prop3=>'vx');
ok(! defined $r->get_property({a1=>1},'prop3'),'undef on generalization, 2');