annotate _test/Test/Object/Common.pm @ 193:8e8401c0aea4

sync
author sergey
date Tue, 10 Apr 2012 08:13:22 +0400
parents 76515373dac0
children ced5937ff21a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
1 package Test::Object::Common;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
4
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
5 use parent qw( IMPL::Test::Unit );
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
6 use IMPL::Test qw(test failed cmparray);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
7
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
8 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
9
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
10 {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
11 package Foo;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
12 use parent qw(IMPL::Object);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
14 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
15 my ($this,$refarg) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
16 $$refarg = 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
17 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
18
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
19 package Bar;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
20 use parent qw(-norequire Foo);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
21
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
22 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
23
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
24 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
25 my ($this,$ref,$array) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
26
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
27 push @$array,__PACKAGE__;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
28 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
30 package Baz;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
31 use parent qw(-norequire Bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
32
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
33 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
34 Bar => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
35 my $t;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
36 (\$t,$_[0]);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
37 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
38 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
39
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
40 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
41 my ($this,$array) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
42 push @$array,__PACKAGE__;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
43 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
44
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
45 package Zoo;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
46 use parent qw(-norequire Bar);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
48 __PACKAGE__->PassThroughArgs;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
50 sub CTOR {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
51 my ($this,$ref,$array) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
52
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
53 push @$array,__PACKAGE__;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
54 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
55
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
56 package Complex;
165
76515373dac0 Added Class::Template,
wizard
parents: 49
diff changeset
57 use parent qw(-norequire Baz Zoo);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
58
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
59 our %CTOR = (
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
60 Baz => sub { @_ },
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
61 Zoo => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
62 my $t;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
63 (\$t,$_[0]);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
64 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
65 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
66
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
67 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
68
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
69 test Creation => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
70 my $flag = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
71
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
72 my $obj = new Foo(\$flag);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
73
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
74 die new IMPL::Test::FailException("Object is undef") unless $obj;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
75 die new IMPL::Test::FailException("Contructor doesn't run") unless $obj;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
76 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
77
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
78 test SimpleInheritance => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
79 my $sequence = [];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
80 my $flag = 0;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
81 my $obj = new Bar(\$flag,$sequence);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
82
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
83 failed "Object is undef" unless $obj;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
84 failed "Base class constructor isn't called" unless $flag;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
85 failed "Class constructor isn't called" unless @$sequence;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
86 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
87
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
88 test SimpleInheritance2 => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
89 my $sequence = [];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
90 my $expected = [qw(Bar Baz)];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
91 my $obj = new Baz($sequence);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
92
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
93 failed "Object is undef" unless $obj;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
94 failed "Wrong constructor sequence","expected: " . join(', ',@$expected),"actual: ".join(', ',@$sequence) unless cmparray $sequence,$expected;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
95 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
96
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
97 test MultipleInheritance => sub {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
98 my $sequence = [];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
99 my $expected = [qw(Bar Baz Bar Zoo)];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
100 my $obj = new Complex($sequence);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
101
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
102 failed "Object is undef" unless $obj;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
103 failed "Wrong constructor sequence","expected: " . join(', ',@$expected),"actual: ".join(', ',@$sequence) unless cmparray $sequence,$expected;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
104 };
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
105
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
106 1;