line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: ActionFixture.pm,v 1.6 2006/06/16 15:20:56 tonyb Exp $ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2002-2005 Cunningham & Cunningham, Inc. |
4
|
|
|
|
|
|
|
# Released under the terms of the GNU General Public License version 2 or later. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# Perl translation by Dave W. Smith |
7
|
|
|
|
|
|
|
# Modified by Tony Byrne |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Test::C2FIT::ActionFixture; |
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
1126
|
use base 'Test::C2FIT::Fixture'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
105
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
14
|
1
|
|
|
1
|
|
6
|
use Test::C2FIT::TypeAdapter; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
15
|
1
|
|
|
1
|
|
6
|
use Error qw( :try ); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
185
|
use vars qw($actor); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
609
|
|
18
|
|
|
|
|
|
|
$actor = undef; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
0
|
|
|
0
|
0
|
|
my $pkg = shift; |
22
|
0
|
|
|
|
|
|
return $pkg->SUPER::new( cells => undef, empty => undef, @_ ); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub doCells { |
26
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
27
|
0
|
|
|
|
|
|
my ($cells) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{'cells'} = $cells; |
30
|
|
|
|
|
|
|
try { |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# N.B. "do_" is prepended to avoid a method collision on "check" |
33
|
0
|
|
|
0
|
|
|
my $method = "do_" . $cells->text(); |
34
|
0
|
|
|
|
|
|
$self->$method(); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
otherwise { |
37
|
0
|
|
|
0
|
|
|
my $e = shift; |
38
|
0
|
|
|
|
|
|
$self->exception( $cells, $e ); |
39
|
0
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Actions |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub do_start { |
45
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
my $pkg = $self->{'cells'}->more()->text(); |
47
|
0
|
|
|
|
|
|
$actor = $self->_createNewInstance($pkg); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub do_enter { |
51
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
|
53
|
0
|
0
|
|
|
|
|
throw Test::C2FIT::Exception("no actor") unless defined($actor); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $method = $self->method(); |
56
|
0
|
|
|
|
|
|
my $text = $self->{'cells'}->more()->more()->text(); |
57
|
0
|
|
|
|
|
|
my $typeAdapter = Test::C2FIT::TypeAdapter->onSetter( $actor, $method ); |
58
|
0
|
|
|
|
|
|
$actor->$method( $typeAdapter->parse($text) ); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub do_press { |
62
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
63
|
0
|
|
|
|
|
|
my $method = $self->method(); |
64
|
0
|
|
|
|
|
|
$actor->$method(); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub do_check { |
68
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
throw Test::C2FIT::Exception("no actor") unless defined($actor); |
71
|
0
|
|
|
|
|
|
my $method = $self->method(); |
72
|
0
|
|
|
|
|
|
my $adapter = Test::C2FIT::TypeAdapter->onMethod( $actor, $self->method() ); |
73
|
0
|
|
|
|
|
|
$self->check( $self->{'cells'}->more()->more(), $adapter ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Utility |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub method { |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my $method = $self->camel( $self->{'cells'}->more()->text() ); |
81
|
0
|
0
|
|
|
|
|
throw Test::C2FIT::Exception("no actor") unless defined($actor); |
82
|
0
|
0
|
|
|
|
|
throw Test::C2FIT::Exception("no such method: $method on $actor\n") |
83
|
|
|
|
|
|
|
unless $actor->can($method); |
84
|
0
|
|
|
|
|
|
return $method; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=pod |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 NAME |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Test::C2FIT::ActionFixture - An action fixture interprets rows as a sequence of commands to be performed in order. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 SYNOPSIS |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Normally, you do not use this class directly, rather you use its name in your FIT-document. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 SEE ALSO |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Extensive and up-to-date documentation on FIT can be found at: |
102
|
|
|
|
|
|
|
http://fit.c2.com/ |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |