summaryrefslogtreecommitdiff
path: root/cpan/version/t/01base.t
blob: 4c1a23dd49928f41be626a4845ad4b029a1b54d8 (plain)
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
37
38
39
40
41
42
43
44
45
46
47
#! /usr/local/perl -w
# Before `make install' is performed this script should be runnable with
# `make test'. After `make install' it should work as `perl test.pl'

#########################

use Test::More qw/no_plan/;
use File::Spec;

BEGIN {
    my $coretests = File::Spec->catpath(
        (File::Spec->splitpath($0))[0,1], 'coretests.pm'
    );
    require $coretests;
    use_ok('version', 0.9914);
}

BaseTests("version","new","qv");
BaseTests("version","new","declare");
BaseTests("version","parse", "qv");
BaseTests("version","parse", "declare");

# dummy up a redundant call to satify David Wheeler
local $SIG{__WARN__} = sub { die $_[0] };
eval 'use version;';
unlike ($@, qr/^Subroutine main::declare redefined/,
    "Only export declare once per package (to prevent redefined warnings).");

# https://rt.cpan.org/Ticket/Display.html?id=47980
my $v = eval {
    require IO::Handle;
    $@ = qq(Can't locate some/completely/fictitious/module.pm);
    return IO::Handle->VERSION;
};
ok defined($v), 'Fix for RT #47980';

{ # https://rt.cpan.org/Ticket/Display.html?id=81085
    eval { version::new() };
    like $@, qr'Usage: version::new\(class, version\)',
	'No bus err when called as function';
    eval { $x = 1; print version::new };
    like $@, qr'Usage: version::new\(class, version\)',
	'No implicit object creation when called as function';
    eval { $x = "version"; print version::new };
    like $@, qr'Usage: version::new\(class, version\)',
	'No implicit object creation when called as function';
}