annotate Lib/IMPL/Test.pm @ 245:7c517134c42f

Added Unsupported media type Web exception corrected resourceLocation setting in the resource Implemented localizable resources for text messages fixed TT view scopings, INIT block in controls now sets globals correctly.
author sergey
date Mon, 29 Oct 2012 03:15:22 +0400
parents 4d0e1962161c
children 6253872024a4
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);
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 165
diff changeset
9 our @EXPORT_OK = qw(&test &shared &failed &cmparray &skip &run_plan &assert &GetCallerSourceLine);
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
165
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
41 sub assert {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
42 my ($condition,@params) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
43
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
44 die new IMPL::Test::FailException(@params ? @params : ("Assertion failed" , _GetSourceLine( (caller)[1,2] )) ) unless $condition;
165
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
45 }
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
46
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
47 sub skip($;@) {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
48 die new IMPL::Test::SkipException(@_);
84
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
49 }
e568c7c8b743 Minor changes to the test infrastructure
wizard
parents: 49
diff changeset
50
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
51 sub cmparray {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
52 my ($a,$b) = @_;
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 0 unless @$a == @$b;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
55
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
56 for (my $i=0; $i < @$a; $i++ ) {
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
57 return 0 unless $a->[$i] eq $b->[$i];
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
58 }
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
59
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
60 return 1;
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
61 }
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
62
165
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
63 sub _GetSourceLine {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
64 my ($file,$line) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
65
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
66 open my $hFile, $file or return "failed to open file: $file: $!";
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
67
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
68 my $text;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
69 $text = <$hFile> for ( 1 .. $line);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
70 chomp $text;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
71 $text =~ s/^\s+//;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
72 return "line $line: $text";
165
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
73 }
76515373dac0 Added Class::Template,
wizard
parents: 159
diff changeset
74
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 165
diff changeset
75 sub GetCallerSourceLine {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
76 my $line = shift || 0;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
77 return _GetSourceLine( (caller($line + 1))[1,2] )
188
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 165
diff changeset
78 }
029c9610528c Memory leak tests in IMPL::Web::View
cin
parents: 165
diff changeset
79
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
80 sub run_plan {
194
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
81 my (@units) = @_;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
82
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
83 my $plan = new IMPL::Test::Plan(@units);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
84
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
85 $plan->Prepare;
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
86 $plan->AddListener(new IMPL::Test::TAPListener);
4d0e1962161c Replaced tabs with spaces
cin
parents: 188
diff changeset
87 $plan->Run;
159
f8de52d3c112 IMPL::Test::Unit minor changes
wizard
parents: 84
diff changeset
88 }
49
16ada169ca75 migrating to the Eclipse IDE
wizard@linux-odin.local
parents: 3
diff changeset
89 1;