165
|
1 package Test::Class::Template;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 use parent qw(IMPL::Test::Unit);
|
|
6
|
|
7 __PACKAGE__->PassThroughArgs;
|
|
8
|
|
9 use IMPL::Test qw(test failed);
|
|
10 use IMPL::lang;
|
|
11
|
|
12 {
|
194
|
13 package My::Collection;
|
|
14 use parent qw(IMPL::Object);
|
|
15 use IMPL::Class::Property;
|
|
16
|
|
17 use IMPL::template (
|
|
18 parameters => [qw(TValue)],
|
|
19 declare => sub {
|
|
20 my ($class) = @_;
|
|
21
|
|
22 public $class->CreateProperty( items => prop_get | owner_set | prop_list, { type => $class->TValue } );
|
|
23 }
|
|
24 );
|
|
25
|
|
26 BEGIN {
|
|
27 public property name => prop_all;
|
|
28 }
|
165
|
29 };
|
|
30
|
|
31 test IsDerivedFromTemplate => sub {
|
194
|
32 failed "My::Collection should be a subclass of IMPL::Class:Template" unless is('My::Collection','IMPL::Class::Template');
|
165
|
33 };
|
|
34
|
|
35 test Specialize => sub {
|
194
|
36 my $colList = spec My::Collection('IMPL::Object::List');
|
|
37 my $colObj = spec My::Collection('IMPL::Object');
|
|
38 my $colList2 = spec My::Collection('IMPL::Object::List');
|
|
39
|
|
40 failed "Wrong class name", "expected: My::ColectionLis", "got: $colList" unless $colList eq 'My::CollectionList';
|
|
41 failed "Wrong template parameter type", "expected: IMPL::Object::List", "got" . $colList->TValue unless $colList->TValue eq 'IMPL::Object::List';
|
|
42
|
165
|
43 };
|
|
44
|
180
|
45 1;
|