This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Synch cpan/version/* and other files with CPAN version 0.9921.
[perl5.git] / cpan / version / t / 01base.t
1 #! /usr/local/perl -w
2 # Before `make install' is performed this script should be runnable with
3 # `make test'. After `make install' it should work as `perl test.pl'
4
5 #########################
6
7 use Test::More qw/no_plan/;
8 use File::Spec;
9
10 BEGIN {
11     my $coretests = File::Spec->rel2abs(
12         File::Spec->catpath(
13             (File::Spec->splitpath($0))[0,1], 'coretests.pm'
14         )
15     );
16     require $coretests;
17     use_ok('version', 0.9921);
18 }
19
20 BaseTests("version","new","qv");
21 BaseTests("version","new","declare");
22 BaseTests("version","parse", "qv");
23 BaseTests("version","parse", "declare");
24
25 # dummy up a redundant call to satify David Wheeler
26 local $SIG{__WARN__} = sub { die $_[0] };
27 eval 'use version;';
28 unlike ($@, qr/^Subroutine main::declare redefined/,
29     "Only export declare once per package (to prevent redefined warnings).");
30
31 # https://rt.cpan.org/Ticket/Display.html?id=47980
32 my $v = eval {
33     require IO::Handle;
34     $@ = qq(Can't locate some/completely/fictitious/module.pm);
35     return IO::Handle->VERSION;
36 };
37 ok defined($v), 'Fix for RT #47980';
38
39 { # https://rt.cpan.org/Ticket/Display.html?id=81085
40     eval { version::new() };
41     like $@, qr'Usage: version::new\(class, version\)',
42         'No bus err when called as function';
43     eval { $x = 1; print version::new };
44     like $@, qr'Usage: version::new\(class, version\)',
45         'No implicit object creation when called as function';
46     eval { $x = "version"; print version::new };
47     like $@, qr'Usage: version::new\(class, version\)',
48         'No implicit object creation when called as function';
49 }