comparison _test/Test/Object/Fields.pm @ 194:4d0e1962161c

Replaced tabs with spaces IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author cin
date Tue, 10 Apr 2012 20:08:29 +0400
parents d1676be8afcc
children
comparison
equal deleted inserted replaced
193:8e8401c0aea4 194:4d0e1962161c
6 use IMPL::Test qw(test failed cmparray); 6 use IMPL::Test qw(test failed cmparray);
7 7
8 __PACKAGE__->PassThroughArgs; 8 __PACKAGE__->PassThroughArgs;
9 9
10 { 10 {
11 package Fields::Foo; 11 package Fields::Foo;
12 use base qw(IMPL::Object::Fields); 12 use base qw(IMPL::Object::Fields);
13 13
14 use fields qw(name info); 14 use fields qw(name info);
15 15
16 sub CTOR { 16 sub CTOR {
17 my ($this,$name,$info) = @_; 17 my ($this,$name,$info) = @_;
18 18
19 $this->{name} = $name; 19 $this->{name} = $name;
20 $this->{info} = $info; 20 $this->{info} = $info;
21 } 21 }
22 22
23 package Fields::Bar; 23 package Fields::Bar;
24 use base qw(Fields::Foo); 24 use base qw(Fields::Foo);
25 use fields qw(id); 25 use fields qw(id);
26 26
27 our %CTOR = ( 27 our %CTOR = (
28 'Fields::Foo' => sub { 28 'Fields::Foo' => sub {
29 my %args = @_; 29 my %args = @_;
30 Bar => $args{info}; 30 Bar => $args{info};
31 } 31 }
32 ); 32 );
33 33
34 sub CTOR { 34 sub CTOR {
35 my ($this,%args) = @_; 35 my ($this,%args) = @_;
36 36
37 $this->{id} = $args{id}; 37 $this->{id} = $args{id};
38 } 38 }
39 } 39 }
40 40
41 test constructObject => sub { 41 test constructObject => sub {
42 my $obj = new Fields::Foo( Peter => '34-fg-78' ); 42 my $obj = new Fields::Foo( Peter => '34-fg-78' );
43 43
44 $obj->{name} eq 'Peter' or failed "A value of 'name' field is wrong","Expected: 'Peter'","Got: '$obj->{name}'"; 44 $obj->{name} eq 'Peter' or failed "A value of 'name' field is wrong","Expected: 'Peter'","Got: '$obj->{name}'";
45 }; 45 };
46 46
47 test inheritance => sub { 47 test inheritance => sub {
48 my $obj = new Fields::Bar( id => '1ba356f', info => 'standard bar'); 48 my $obj = new Fields::Bar( id => '1ba356f', info => 'standard bar');
49 49
50 $obj->{name} eq 'Bar' or failed "A value of 'name' property is wrong","Expected: 'Bar'","Got: '$obj->{name}'"; 50 $obj->{name} eq 'Bar' or failed "A value of 'name' property is wrong","Expected: 'Bar'","Got: '$obj->{name}'";
51 $obj->{id} eq '1ba356f' or failed "A value of 'id' property is wrong","Expected: '1ba356f'","Got: '$obj->{id}'"; 51 $obj->{id} eq '1ba356f' or failed "A value of 'id' property is wrong","Expected: '1ba356f'","Got: '$obj->{id}'";
52 }; 52 };
53 53
54 1; 54 1;