File: require.t

package info (click to toggle)
libuniversal-require-perl 0.10-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 64 kB
  • ctags: 12
  • sloc: perl: 115; makefile: 42
file content (36 lines) | stat: -rw-r--r-- 1,079 bytes parent folder | download
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
36
#!/usr/bin/perl -Tw

use Test::More tests => 11;
use_ok "UNIVERSAL::require";

use lib qw(t);


is( Dummy->require,               23,           'require()' );
is( $UNIVERSAL::require::ERROR,   '',           '  $ERROR empty' );
ok( $Dummy::VERSION,                            '  $VERSION ok' );

{
    $SIG{__WARN__} = sub { warn @_ 
                             unless $_[0] =~ /^Subroutine \w+ redefined/ };
    delete $INC{'Dummy.pm'};
    is( Dummy->require(0.4), 23,                  'require($version)' );
    is( $UNIVERSAL::require::ERROR, '',           '  $ERROR empty' );

    delete $INC{'Dummy.pm'};
    ok( !Dummy->require(1.0),                       'require($version) fail' );
    like( $UNIVERSAL::require::ERROR,
          '/^Dummy version 1 required--this is only version 0.5/' );
}

{
    my $warning = '';
    local $SIG{__WARN__} = sub { $warning = join '', @_ };
    eval 'use UNIVERSAL';
    is( $warning, '',     'use UNIVERSAL doesnt interfere' );
}


my $evil = "Dummy; Test::More::fail('this should never be called');";
ok !$evil->require;
isnt $@, '';