File: synopsis.t

package info (click to toggle)
libhtml-truncate-perl 0.20-1~bpo8%2B1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-backports
  • size: 292 kB
  • sloc: perl: 2,339; makefile: 2
file content (35 lines) | stat: -rw-r--r-- 777 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use strict;

use FindBin;
use File::Spec;
use lib File::Spec->catfile($FindBin::Bin, 'lib');
use Config;

use Test::More tests => 2;

#------------------------------------------------------------------
my $dir = $ENV{ADTTMP} ? $Config{vendorlib} : "$FindBin::Bin/../lib";
open F, '<', "$dir/HTML/Truncate.pm"
    or die "Couldn't open self module to read!";

my $synopsis = '';
while ( <F> ) {
    if ( /=head1 SYNOPSIS/i .. /=head\d (?!S)/
                   and not /^=/ )
    {
        $synopsis .= $_;
    }
}
close F;

ok( $synopsis,
    "Got code out of the SYNOPSIS space to evaluate" );

diag( $synopsis ) if $ENV{TEST_VERBOSE};


my $ok = eval "$synopsis; print qq{\n}; 1;";

ok( $ok,  "Synopsis eval'd" );

diag( $@ . "\n" . $synopsis ) if $@ and $ENV{TEST_VERBOSE};