annotate _test/Test/Class/Template.pm @ 250:129e48bb5afb

DOM refactoring ObjectToDOM methods are virtual QueryToDOM uses inflators Fixed transform for the complex values in the ObjectToDOM QueryToDOM doesn't allow to use complex values (HASHes) as values for nodes (overpost problem)
author sergey
date Wed, 07 Nov 2012 04:17:53 +0400
parents 4d0e1962161c
children 56364d0c4b4f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
1 package Test::Class::Template;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
2 use strict;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
3 use warnings;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
4
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
5 use parent qw(IMPL::Test::Unit);
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
6
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
7 __PACKAGE__->PassThroughArgs;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
8
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
9 use IMPL::Test qw(test failed);
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
10 use IMPL::lang;
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
11
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
12 {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
13 package My::Collection;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
14 use parent qw(IMPL::Object);
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
15 use IMPL::Class::Property;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
16
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
17 use IMPL::template (
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
18 parameters => [qw(TValue)],
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
19 declare => sub {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
20 my ($class) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
21
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
22 public $class->CreateProperty( items => prop_get | owner_set | prop_list, { type => $class->TValue } );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
23 }
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
24 );
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
25
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
26 BEGIN {
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
27 public property name => prop_all;
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
28 }
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
29 };
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
30
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
31 test IsDerivedFromTemplate => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
32 failed "My::Collection should be a subclass of IMPL::Class:Template" unless is('My::Collection','IMPL::Class::Template');
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
33 };
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
34
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
35 test Specialize => sub {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
36 my $colList = spec My::Collection('IMPL::Object::List');
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
37 my $colObj = spec My::Collection('IMPL::Object');
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
38 my $colList2 = spec My::Collection('IMPL::Object::List');
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
39
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
40 failed "Wrong class name", "expected: My::ColectionLis", "got: $colList" unless $colList eq 'My::CollectionList';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
41 failed "Wrong template parameter type", "expected: IMPL::Object::List", "got" . $colList->TValue unless $colList->TValue eq 'IMPL::Object::List';
4d0e1962161c Replaced tabs with spaces
cin
parents: 180
diff changeset
42
165
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
43 };
76515373dac0 Added Class::Template,
wizard
parents:
diff changeset
44
180
d1676be8afcc Перекодировка в utf-8
sourcer
parents: 165
diff changeset
45 1;