annotate _test/Test/Class/Template.pm @ 411:ee36115f6a34 ref20150831

sync
author cin
date Mon, 21 Sep 2015 00:53:10 +0300
parents 4ddb27ff4a0b
children
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
278
4ddb27ff4a0b core refactoring
cin
parents: 271
diff changeset
22 $class->CreateProperty( items => prop_get | owner_set | prop_list, { type => $class->TValue } );
194
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 {
271
56364d0c4b4f +IMPL::SQL::Schema::MySQL: added basic support for MySQL
cin
parents: 194
diff changeset
32 failed "My::Collection should be a subclass of IMPL::Class:Template" unless isclass('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;