90
|
1 use strict;
|
|
2
|
|
3 package Test::Class::Meta;
|
165
|
4 use parent qw(IMPL::Test::Unit);
|
90
|
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;
|
165
|
49 use parent qw(IMPL::Class::Meta);
|
90
|
50
|
|
51 package Bar;
|
165
|
52 use parent qw(-norequire Foo);
|
90
|
53
|
|
54 package Baz;
|
165
|
55 use parent qw(-norequire Foo);
|
90
|
56
|
|
57 1;
|