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
CommitLineData
543eec9e
JP
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
7use Test::More qw/no_plan/;
14f3031b 8use File::Spec;
543eec9e
JP
9
10BEGIN {
dddb2275
JP
11 my $coretests = File::Spec->rel2abs(
12 File::Spec->catpath(
13 (File::Spec->splitpath($0))[0,1], 'coretests.pm'
14 )
14f3031b 15 );
543eec9e 16 require $coretests;
d3a5b29c 17 use_ok('version', 0.9921);
543eec9e
JP
18}
19
543eec9e
JP
20BaseTests("version","new","qv");
21BaseTests("version","new","declare");
22BaseTests("version","parse", "qv");
23BaseTests("version","parse", "declare");
24
25# dummy up a redundant call to satify David Wheeler
26local $SIG{__WARN__} = sub { die $_[0] };
27eval 'use version;';
28unlike ($@, 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
32my $v = eval {
33 require IO::Handle;
34 $@ = qq(Can't locate some/completely/fictitious/module.pm);
35 return IO::Handle->VERSION;
36};
37ok defined($v), 'Fix for RT #47980';
b2a8d771
JP
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}