| 1 | #!perl -w | ||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||
| 3 | package ClassWithTestsAtTheEnd; | ||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||
| 9 | B<ClassWithTestsAtTheEnd> - Demonstrating putting synopsis tests at | ||||||||||||||||||||||||||||||
| 10 | the end of an object class, L<perlmodlib>-style | ||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||
| 12 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||
| 14 | =for test "synopsis" begin | ||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||
| 16 | my $foo = new ClassWithTestsAtTheEnd; | ||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||
| 18 | $foo->zonk(); | ||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||
| 20 | =for test "synopsis" end | ||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||
| 24 | This is a dud class to demonstrate a particular use of | ||||||||||||||||||||||||||||||
| 25 | L<Pod::Snippets> that its author finds convenient (nay: way groovy | ||||||||||||||||||||||||||||||
| 26 | actually). | ||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||
| 28 | First we have some foo-ness so that we can pretend we are a real | ||||||||||||||||||||||||||||||
| 29 | package. | ||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | sub new { bless {}, shift } | ||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | sub zonk { "GLORPS" } | ||||||||||||||||||||||||||||
|
Subroutine
zonk: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||
| 37 | 2 | ▶ | sub foo { "barracuda" } | ||||||||||||||||||||||||||||
|
Subroutine
foo: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||
| 39 | =head1 TEST SUITE | ||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||
| 41 | The test suite is introduced by the "unless caller" mantra straight | ||||||||||||||||||||||||||||||
| 42 | from L<perlmodlib>. "unless caller" means that the test suite won't | ||||||||||||||||||||||||||||||
| 43 | even be compiled if we have a caller, that is, the library is being | ||||||||||||||||||||||||||||||
| 44 | invoked with "use" or "require". If one executes the library directly | ||||||||||||||||||||||||||||||
| 45 | (as in C<perl ClassWithTestsAtTheEnd.pm>), the test suite is fired up. | ||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||
| 47 | =cut | ||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||
| 49 | 1 | ▶ | eval join('',<main::DATA>) || die $@ unless caller(); | ||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
BEGIN: called CC=1 SCAR=0.1
Subroutine
BEGIN: called CC=1 SCAR=0.1
Branch: 1 branch
Condition50%2/4
caller() || (eval join('', readline main::DATA) || die($@))
eval join("", readline main::DATA) or die $@
MC/DC0%0/2
caller() || (eval join('', readline main::DATA) || die($@))
caller()
eval join("", readline main::DATA)
Truth table33%1/3
A || B
A= caller()B= eval join("", readline main::DATA)
| |||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||
| 51 | 1; | ||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||||