File: 01-load.t

package info (click to toggle)
libsystem-command-perl 1.07-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 144 kB
  • sloc: perl: 170; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 742 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
use strict;
use warnings;
use Test::More;

my @tests = (
    [ q{use System::Command},         0 ],
    [ q{use System::Command 'quiet'}, 1 ],
    [ q{use System::Command -quiet},  1 ],
    [ q{use System::Command 'verbose'}, undef, qr/^Unknown option 'verbose'/ ],
    [ q{use System::Command -verbose},  undef, qr/^Unknown option 'verbose'/ ],
);

plan tests => 2 * @tests;

for my $t (@tests) {
    my ( $code, $expected, $at ) = @$t;

    # clean up
    no warnings 'once';
    delete $INC{'System/Command.pm'};
    $System::Command::QUIET = 0;

    # test
    local $SIG{__WARN__} = sub { };
    is( eval "$code; \$System::Command::QUIET", $expected, $code );
    like( $@, $at || qr/^$/, 'use ' . ( $at ? 'failed' : 'succeeded' ) );
}