0
|
1 package IMPL::Test;
|
|
2 use strict;
|
|
3 use warnings;
|
|
4
|
|
5 require Exporter;
|
|
6 our @ISA = qw(Exporter);
|
3
|
7 our @EXPORT_OK = qw(&test &shared &failed &cmparray);
|
0
|
8
|
|
9 require IMPL::Test::Unit;
|
|
10 use IMPL::Class::Member;
|
|
11
|
|
12 sub test($$) {
|
|
13 my ($name,$code) = @_;
|
|
14 my $class = caller;
|
|
15
|
|
16 $class->set_meta(
|
|
17 new IMPL::Test::Unit::TestInfo( $name, $code )
|
|
18 );
|
|
19 }
|
|
20
|
|
21 sub shared($) {
|
|
22 my ($propInfo) = @_;
|
|
23
|
|
24 my $class = caller;
|
|
25
|
|
26 die new IMPL::Exception("Only properties could be declared as shared",$propInfo->Name) unless eval {$propInfo->isa('IMPL::Class::PropertyInfo')};
|
|
27 die new IMPL::Exception("You can't mark the readonly property as shared",$propInfo->Name) unless $propInfo->canSet;
|
|
28 die new IMPL::Exception("Only public properties could be declared as shared",$propInfo->Name) unless $propInfo->Access == IMPL::Class::Member::MOD_PUBLIC;
|
|
29
|
|
30 $class->set_meta(new IMPL::Test::Unit::SharedData($propInfo->Name));
|
|
31 }
|
3
|
32
|
|
33 sub failed($;@) {
|
|
34 die new IMPL::Test::FailException(@_);
|
|
35 }
|
|
36
|
|
37 sub cmparray {
|
|
38 my ($a,$b) = @_;
|
|
39
|
|
40 return 0 unless @$a == @$b;
|
|
41
|
|
42 for (my $i=0; $i < @$a; $i++ ) {
|
|
43 return 0 unless $a->[$i] eq $b->[$i];
|
|
44 }
|
|
45
|
|
46 return 1;
|
|
47 }
|
0
|
48 1;
|