comparison _test/Test/Class/Meta.pm @ 90:dc1da0389db7

Small improvements in the abstract object class Added support for a class data, documentation Additional tests for the new functionality
author wizard
date Mon, 26 Apr 2010 03:10:03 +0400
parents
children 76515373dac0
comparison
equal deleted inserted replaced
89:3d1f584aea60 90:dc1da0389db7
1 use strict;
2
3 package Test::Class::Meta;
4 use base qw(IMPL::Test::Unit);
5
6 __PACKAGE__->PassThroughArgs;
7
8 use IMPL::Test qw(test failed);
9
10 test defineFooClassData => sub {
11 Foo->class_data(info => {});
12 };
13
14 test updateFooClassData => sub {
15 Foo->class_data('info')->{data} = 'Foo' ;
16 };
17
18 test getFooClassData => sub {
19 failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data} unless Foo->class_data('info')->{data} eq 'Foo';
20 };
21
22 test getBazClassData => sub {
23 failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data} unless Baz->class_data('info')->{data} eq 'Foo';
24 };
25
26 test updateBarClassData => sub {
27 Bar->class_data('info')->{data} = 'Bar';
28 };
29
30 test getBarClassData => sub {
31 failed "Wrong class data", "Expected: Bar", "Got: ".Bar->class_data('info')->{data} unless Bar->class_data('info')->{data} eq 'Bar';
32 };
33
34 test validatetFooClassData => sub {
35 failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data} unless Foo->class_data('info')->{data} eq 'Foo';
36 };
37
38 test validateBazClassData => sub {
39 failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data} unless Baz->class_data('info')->{data} eq 'Foo';
40 };
41
42 test getwrongBazClassData => sub {
43 failed "Wrong class data", "Expected: undef", "Got: ".Foo->class_data( 'info2' ) if Foo->class_data( 'info2' );
44 };
45
46
47
48 package Foo;
49 use base qw(IMPL::Class::Meta);
50
51 package Bar;
52 use base qw(Foo);
53
54 package Baz;
55 use base qw(Foo);
56
57 1;