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/; 8use File::Spec; 9 10BEGIN { 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.9924); 18} 19 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'; 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} 50