File: 03import.t

package info (click to toggle)
libpod-coverage-perl 0.23-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 240 kB
  • sloc: perl: 611; makefile: 7
file content (32 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/perl -w
use strict;
use lib 't/lib';
use Test::More tests => 3;


is( capture(q{ use Pod::Coverage package => 'Simple2'; }), "Simple2 has a Pod::Coverage rating of 0.75\n'naked' is uncovered", "Simple2 works correctly in import form");

is( capture(q{ use Pod::Coverage package => 'Simple7' }), "Simple7 has a Pod::Coverage rating of 0\nThe following are uncovered: bar, foo", 'Simple7 import form');

is( capture(q{ use Pod::Coverage 'Simple7' }), "Simple7 has a Pod::Coverage rating of 0\nThe following are uncovered: bar, foo", 'Simple7 import form, implicit package');

sub capture {
    my $code = shift;
    open(FH, ">test.out") or die "Couldn't open test.out for writing: $!";
    open(OLDOUT, ">&STDOUT");
    select(select(OLDOUT));
    open(STDOUT, ">&FH");

    eval $code;

    close STDOUT;
    close FH;
    open(STDOUT, ">&OLDOUT");
    open(FH, "<test.out") or die "Couldn't open test.out for reading: $!";
    my $result;
    { local $/; $result = <FH>; }
    chomp $result;
    close FH;
    unlink('test.out');
    return $result;
}