lib/Test/FitNesse/Slim/SlimHelperLibrary.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 4 / 4 totaltotal 100% 37 / 37 CC 3 SCAR 4.1
CC
3
Cov
100%
get_fixture
2.0
pop_fixture
2.0
BEGIN
1.0
CRAP 1.5
« lib/Test/FitNesse/Slim/ListExecutor.pm ↑ Summary bin/perl-slim »
1 package Test::FitNesse::Slim::SlimHelperLibrary;
2  
3 82 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 82 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 174 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
7 174 my($class,$instances) = @_;
8 174 bless {
9 instances => $instances,
10 stack => [],
11 } => $class;
12 }
13  
14 9 ▶sub get_fixture {
Subroutine get_fixture: called CC=2 SCAR=6.9
Pod documented
15 9 my($self) = @_;
16 9 my $fixture = $self->{instances}{scriptTableActor};
17 9 ▶ die "NO_INSTANCE scriptTableActor." unless defined $fixture;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fixture 1 8 9
18 8 $fixture;
19 }
20  
21 4 ▶sub push_fixture {
Subroutine push_fixture: called CC=1 SCAR=0.0
Pod documented
22 4 my($self) = @_;
23 4 push @{ $self->{stack} }, $self->get_fixture;
24 4 return;
25 }
26  
27 5 ▶sub pop_fixture {
Subroutine pop_fixture: called CC=2 SCAR=6.9
Pod documented
28 5 my($self) = @_;
29 5 ▶ die "EmptyStackException" unless @{ $self->{stack} };
Branch: 1 branch
BranchTrueFalseTotal
unless @{$self->{"stack"};} 1 4 5
30 4 $self->{instances}{scriptTableActor} = pop @{ $self->{stack} };
31 4 return;
32 }
33  
34 82 1;
35  
36 =head1 NAME
37  
38 Test::FitNesse::Slim::SlimHelperLibrary - Maintain FitNesse script-table fixture state
39  
40 =head1 DESCRIPTION
41  
42 Each statement executor creates a private helper-library instance. Its
43 stack saves and restores the current C<scriptTableActor> reference used by
44 FitNesse script tables. The stack belongs to one SLiM session and preserves
45 object identity.
46  
47 =head1 METHODS
48  
49 =head2 new
50  
51 my $library = Test::FitNesse::Slim::SlimHelperLibrary->new(\%instances);
52  
53 Create a helper bound to the executor's instance hash. The hash is retained
54 by reference so fixture changes are visible to helper operations.
55  
56 =head2 get_fixture
57  
58 Return the current C<scriptTableActor>. If no actor is registered, throw
59 the FitNesse-compatible C<NO_INSTANCE> error.
60  
61 =head2 push_fixture
62  
63 Save the current fixture reference on the helper's LIFO stack. Return no
64 value.
65  
66 =head2 pop_fixture
67  
68 Restore the most recently saved fixture. An empty stack throws
69 C<EmptyStackException> and leaves the instance hash unchanged.
70  
71 =cut
« lib/Test/FitNesse/Slim/ListExecutor.pm ↑ Summary bin/perl-slim »