xref: /openbsd/gnu/usr.bin/perl/cpan/version/t/01base.t (revision cecf84d4)
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;
12    use_ok('version', 0.9909);
13}
14
15BaseTests("version","new","qv");
16BaseTests("version","new","declare");
17BaseTests("version","parse", "qv");
18BaseTests("version","parse", "declare");
19
20# dummy up a redundant call to satify David Wheeler
21local $SIG{__WARN__} = sub { die $_[0] };
22eval 'use version;';
23unlike ($@, qr/^Subroutine main::declare redefined/,
24    "Only export declare once per package (to prevent redefined warnings).");
25
26# https://rt.cpan.org/Ticket/Display.html?id=47980
27my $v = eval {
28    require IO::Handle;
29    $@ = qq(Can't locate some/completely/fictitious/module.pm);
30    return IO::Handle->VERSION;
31};
32ok defined($v), 'Fix for RT #47980';
33
34{ # https://rt.cpan.org/Ticket/Display.html?id=81085
35    eval { version::new() };
36    like $@, qr'Usage: version::new\(class, version\)',
37	'No bus err when called as function';
38    eval { $x = 1; print version::new };
39    like $@, qr'Usage: version::new\(class, version\)',
40	'No implicit object creation when called as function';
41    eval { $x = "version"; print version::new };
42    like $@, qr'Usage: version::new\(class, version\)',
43	'No implicit object creation when called as function';
44}
45