This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bring core up to version-0.9902
[perl5.git] / lib / 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/;
8
9BEGIN {
10 (my $coretests = $0) =~ s'[^/]+\.t'coretests.pm';
11 require $coretests;
b2a8d771 12 use_ok('version', 0.9902);
543eec9e
JP
13}
14
15diag "Tests with base class" unless $ENV{PERL_CORE};
16
17BaseTests("version","new","qv");
18BaseTests("version","new","declare");
19BaseTests("version","parse", "qv");
20BaseTests("version","parse", "declare");
21
22# dummy up a redundant call to satify David Wheeler
23local $SIG{__WARN__} = sub { die $_[0] };
24eval 'use version;';
25unlike ($@, qr/^Subroutine main::declare redefined/,
26 "Only export declare once per package (to prevent redefined warnings).");
27
28# https://rt.cpan.org/Ticket/Display.html?id=47980
29my $v = eval {
30 require IO::Handle;
31 $@ = qq(Can't locate some/completely/fictitious/module.pm);
32 return IO::Handle->VERSION;
33};
34ok defined($v), 'Fix for RT #47980';
b2a8d771
JP
35
36{ # https://rt.cpan.org/Ticket/Display.html?id=81085
37 eval { version::new() };
38 like $@, qr'Usage: version::new\(class, version\)',
39 'No bus err when called as function';
40 eval { $x = 1; print version::new };
41 like $@, qr'Usage: version::new\(class, version\)',
42 'No implicit object creation when called as function';
43 eval { $x = "version"; print version::new };
44 like $@, qr'Usage: version::new\(class, version\)',
45 'No implicit object creation when called as function';
46}