annotate _test/Test/Object/Fields.pm @ 174:d920d2b70230

minor changes
author sergey
date Tue, 04 Oct 2011 17:55:38 +0400
parents eb3e9861a761
children d1676be8afcc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
164
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
1 package Test::Object::Fields;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
2 use strict;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
3 use warnings;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
4
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
5 use base qw( IMPL::Test::Unit );
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
6 use IMPL::Test qw(test failed cmparray);
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
7
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
8 __PACKAGE__->PassThroughArgs;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
9
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
10 {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
11 package Fields::Foo;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
12 use base qw(IMPL::Object::Fields);
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
13
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
14 use fields qw(name info);
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
15
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
16 sub CTOR {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
17 my ($this,$name,$info) = @_;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
18
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
19 $this->{name} = $name;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
20 $this->{info} = $info;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
21 }
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
22
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
23 package Fields::Bar;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
24 use base qw(Fields::Foo);
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
25 use fields qw(id);
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
26
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
27 our %CTOR = (
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
28 'Fields::Foo' => sub {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
29 my %args = @_;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
30 Bar => $args{info};
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
31 }
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
32 );
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
33
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
34 sub CTOR {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
35 my ($this,%args) = @_;
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
36
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
37 $this->{id} = $args{id};
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
38 }
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
39 }
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
40
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
41 test constructObject => sub {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
42 my $obj = new Fields::Foo( Peter => '34-fg-78' );
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
43
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
44 $obj->{name} eq 'Peter' or failed "A value of 'name' field is wrong","Expected: 'Peter'","Got: '$obj->{name}'";
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
45 };
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
46
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
47 test inheritance => sub {
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
48 my $obj = new Fields::Bar( id => '1ba356f', info => 'standard bar');
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
49
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
50 $obj->{name} eq 'Bar' or failed "A value of 'name' property is wrong","Expected: 'Bar'","Got: '$obj->{name}'";
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
51 $obj->{id} eq '1ba356f' or failed "A value of 'id' property is wrong","Expected: '1ba356f'","Got: '$obj->{id}'";
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
52 };
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
53
eb3e9861a761 SQL traits in progress
wizard
parents:
diff changeset
54 1;