annotate Lib/IMPL/Test.pm @ 130:06a34c197b05

Added support for utf-8 and old versions of CGI module
author wizard
date Wed, 16 Jun 2010 01:50:56 +0400
parents e568c7c8b743
children f8de52d3c112
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
1 package IMPL::Test;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
2 use strict;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
3 use warnings;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
4
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
5 require IMPL::Test::SkipException;
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
6
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
7 require Exporter;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
8 our @ISA = qw(Exporter);
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
9 our @EXPORT_OK = qw(&test &shared &failed &cmparray &skip);
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
10
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
11 require IMPL::Test::Unit;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
12 use IMPL::Class::Member;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
13
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
14 sub test($$) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
15 my ($name,$code) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
16 my $class = caller;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
17
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
18 $class->set_meta(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
19 new IMPL::Test::Unit::TestInfo( $name, $code )
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
20 );
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
21 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
22
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
23 sub shared($) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
24 my ($propInfo) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
25
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
26 my $class = caller;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
27
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
28 die new IMPL::Exception("Only properties could be declared as shared",$propInfo->Name) unless eval {$propInfo->isa('IMPL::Class::PropertyInfo')};
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
29 die new IMPL::Exception("You can't mark the readonly property as shared",$propInfo->Name) unless $propInfo->canSet;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
30 die new IMPL::Exception("Only public properties could be declared as shared",$propInfo->Name) unless $propInfo->Access == IMPL::Class::Member::MOD_PUBLIC;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
31
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
32 $class->set_meta(new IMPL::Test::Unit::SharedData($propInfo->Name));
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
33 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
34
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
35 sub failed($;@) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
36 die new IMPL::Test::FailException(@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
37 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
38
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
39 sub skip($;@) {
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
40 die new IMPL::Test::SkipException(@_);
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
41 }
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
42
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
43 sub cmparray {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
44 my ($a,$b) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
45
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
46 return 0 unless @$a == @$b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
47
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
48 for (my $i=0; $i < @$a; $i++ ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
49 return 0 unless $a->[$i] eq $b->[$i];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
50 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
51
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
52 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
53 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
54 1;