annotate _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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
90
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
1 use strict;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
2
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
3 package Test::Class::Meta;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
4 use base qw(IMPL::Test::Unit);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
5
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
6 __PACKAGE__->PassThroughArgs;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
7
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
8 use IMPL::Test qw(test failed);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
9
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
10 test defineFooClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
11 Foo->class_data(info => {});
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
12 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
13
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
14 test updateFooClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
15 Foo->class_data('info')->{data} = 'Foo' ;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
16 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
17
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
18 test getFooClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
19 failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data} unless Foo->class_data('info')->{data} eq 'Foo';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
20 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
21
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
22 test getBazClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
23 failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data} unless Baz->class_data('info')->{data} eq 'Foo';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
24 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
25
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
26 test updateBarClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
27 Bar->class_data('info')->{data} = 'Bar';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
28 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
29
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
30 test getBarClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
31 failed "Wrong class data", "Expected: Bar", "Got: ".Bar->class_data('info')->{data} unless Bar->class_data('info')->{data} eq 'Bar';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
32 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
33
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
34 test validatetFooClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
35 failed "Wrong class data", "Expected: Foo", "Got: ".Foo->class_data('info')->{data} unless Foo->class_data('info')->{data} eq 'Foo';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
36 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
37
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
38 test validateBazClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
39 failed "Wrong class data", "Expected: Foo", "Got: ".Baz->class_data('info')->{data} unless Baz->class_data('info')->{data} eq 'Foo';
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
40 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
41
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
42 test getwrongBazClassData => sub {
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
43 failed "Wrong class data", "Expected: undef", "Got: ".Foo->class_data( 'info2' ) if Foo->class_data( 'info2' );
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
44 };
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
45
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
46
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
47
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
48 package Foo;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
49 use base qw(IMPL::Class::Meta);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
50
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
51 package Bar;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
52 use base qw(Foo);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
53
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
54 package Baz;
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
55 use base qw(Foo);
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
56
dc1da0389db7 Small improvements in the abstract object class
wizard
parents:
diff changeset
57 1;