annotate Lib/IMPL/Test.pm @ 159:f8de52d3c112

IMPL::Test::Unit minor changes
author wizard
date Mon, 27 Dec 2010 01:37:44 +0300
parents e568c7c8b743
children 76515373dac0
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);
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
9 our @EXPORT_OK = qw(&test &shared &failed &cmparray &skip &run_plan);
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;
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
12 require IMPL::Test::Plan;
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
13 require IMPL::Test::TAPListener;
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
14 use IMPL::Class::Member;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
15
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
16 sub test($$) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
17 my ($name,$code) = @_;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
18 my $class = caller;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
19
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
20 $class->set_meta(
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
21 new IMPL::Test::Unit::TestInfo( $name, $code )
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 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
24
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
25 sub shared($) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
26 my ($propInfo) = @_;
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 my $class = caller;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
29
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
30 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
31 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
32 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
33
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
34 $class->set_meta(new IMPL::Test::Unit::SharedData($propInfo->Name));
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
35 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
36
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
37 sub failed($;@) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
38 die new IMPL::Test::FailException(@_);
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
39 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
40
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
41 sub skip($;@) {
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
42 die new IMPL::Test::SkipException(@_);
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
43 }
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
44
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
45 sub cmparray {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
46 my ($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 return 0 unless @$a == @$b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
50 for (my $i=0; $i < @$a; $i++ ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
51 return 0 unless $a->[$i] eq $b->[$i];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
52 }
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 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
55 }
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
56
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
57 sub run_plan {
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
58 my (@units) = @_;
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
59
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
60 my $plan = new IMPL::Test::Plan(@units);
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
61
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
62 $plan->Prepare;
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
63 $plan->AddListener(new IMPL::Test::TAPListener);
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
64 $plan->Run;
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
65 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
66 1;